问题:如何让PyLint识别numpy成员?

我在Python项目上运行PyLint。PyLint抱怨无法找到numpy成员。在避免跳过成员资格检查的同时如何避免这种情况。

从代码:

import numpy as np

print np.zeros([1, 4])

运行时,我得到了预期的结果:

[[0. 0. 0. 0.]]

但是,pylint给了我这个错误:

E:3,6:模块’numpy’没有’zeros’成员(no-member)

对于版本,我使用的是pylint 1.0.0(星号1.0.1,常见的0.60.0),并尝试使用numpy 1.8.0。

I am running PyLint on a Python project. PyLint makes many complaints about being unable to find numpy members. How can I avoid this while avoiding skipping membership checks.

From the code:

import numpy as np

print np.zeros([1, 4])

Which, when ran, I get the expected:

[[ 0. 0. 0. 0.]]

However, pylint gives me this error:

E: 3, 6: Module ‘numpy’ has no ‘zeros’ member (no-member)

For versions, I am using pylint 1.0.0 (astroid 1.0.1, common 0.60.0) and trying to work with numpy 1.8.0 .


回答 0

如果将Visual Studio Code与Don Jayamanne的出色Python扩展一起使用,请将用户设置添加到numpy白名单:

{
    // whitelist numpy to remove lint errors
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=numpy"
    ]
}

If using Visual Studio Code with Don Jayamanne’s excellent Python extension, add a user setting to whitelist numpy:

{
    // whitelist numpy to remove lint errors
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=numpy"
    ]
}

回答 1

我这里有同样的问题,即使所有相关的软件包的最新版本(astroid 1.3.2logilab_common 0.63.2pylon 1.4.0)。

以下解决方案非常有用:在该部分中,numpy我通过修改pylintrc文件将其添加到了被忽略的模块列表中[TYPECHECK]

[TYPECHECK]

ignored-modules = numpy

根据错误,您可能还需要添加以下行(仍在中[TYPECHECK] section):

ignored-classes = numpy

I had the same issue here, even with the latest versions of all related packages (astroid 1.3.2, logilab_common 0.63.2, pylon 1.4.0).

The following solution worked like a charm: I added numpy to the list of ignored modules by modifying my pylintrc file, in the [TYPECHECK] section:

[TYPECHECK]

ignored-modules = numpy

Depending on the error, you might also need to add the following line (still in the [TYPECHECK] section):

ignored-classes = numpy

回答 2

对于正在处理的一个小numpy项目,我遇到了相同的错误,因此决定忽略numpy模块就可以了。我创建了一个.pylintrc文件:

$ pylint --generate-rcfile > ~/.pylintrc

根据paduwan和j_houg的建议,我修改了以下部分:

[MASTER]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy

[TYPECHECK]

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=numpy

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
ignored-classes=numpy

它“解决”了我的问题。

I was getting the same error for a small numpy project I was working on and decided that ignoring the numpy modules would do just fine. I created a .pylintrc file with:

$ pylint --generate-rcfile > ~/.pylintrc

and following paduwan’s and j_houg’s advice I modified the following sectors:

[MASTER]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy

and

[TYPECHECK]

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=numpy

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This supports can work
# with qualified names.
ignored-classes=numpy

and it “fixed” my issue.


回答 3

在最新版本的pylint中,您可以添加--extension-pkg-whitelist=numpy到pylint命令中。他们以不安全的方式解决了早期版本中的此问题。现在,如果希望他们更加仔细地查看标准库之外的软件包,则必须将其明确列入白名单。看这里。

In recent versions of pylint you can add --extension-pkg-whitelist=numpy to your pylint command. They had fixed this problem in an earlier version in an unsafe way. Now if you want them to look more carefully at a package outside of the standard library, you must explicitly whitelist it. See here.


回答 4

由于这是google中的最高结果,它给我的印象是您必须忽略所有文件中的警告:

这个问题实际上已经在上个月的pylint / astroid来源https://bitbucket.org/logilab/astroid/commits/83d78af4866be5818f193360c78185e1008fd29e的来源中得到解决, 但尚未在Ubuntu软件包中。

要获取来源,只需

hg clone https://bitbucket.org/logilab/pylint/
hg clone https://bitbucket.org/logilab/astroid
mkdir logilab && touch logilab/__init__.py
hg clone http://hg.logilab.org/logilab/common logilab/common
cd pylint && python setup.py install

因此,最后一步很可能需要一个sudo,当然您也需要一些技巧来克隆。

Since this is the top result in google and it gave me the impression that you have to ignore those warnings in all files:

The problem has actually been fixed in the sources of pylint/astroid last month https://bitbucket.org/logilab/astroid/commits/83d78af4866be5818f193360c78185e1008fd29e but are not yet in the Ubuntu packages.

To get the sources, just

hg clone https://bitbucket.org/logilab/pylint/
hg clone https://bitbucket.org/logilab/astroid
mkdir logilab && touch logilab/__init__.py
hg clone http://hg.logilab.org/logilab/common logilab/common
cd pylint && python setup.py install

whereby the last step will most likely require a sudo and of course you need mercurial to clone.


回答 5

为了忽略numpy.core属性产生的所有错误,我们现在可以使用:

$ pylint a.py --generated-members=numpy.*

作为另一个解决方案,将此选项添加到〜/ .pylintrc/ etc / pylintrc文件中:

[TYPECHECK]

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=numpy.*

到目前为止,对于有问题的代码来说,这似乎是多余的,但对于另一个模块(即,)仍然很重要。netifaces

For ignoring all the errors generated by numpy.core‘s attributes, we can now use:

$ pylint a.py --generated-members=numpy.*

As another solution, add this option to ~/.pylintrc or /etc/pylintrc file:

[TYPECHECK]

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=numpy.*

For mentioned in question code by now this seems reduntant, but still matters for another modules, ie. netifaces and etc.


回答 6

如果您不想添加更多配置,请将此代码添加到您的配置文件中,而不是“ whitelist”。

{
"python.linting.pylintArgs": ["--generate-members"],
}

If you don’t want to add more config, please add this code to your config file, instead of ‘whitelist’.

{
"python.linting.pylintArgs": ["--generate-members"],
}

回答 7

在过去的几年中,有许多关于此的错误报告,即https://bitbucket.org/logilab/pylint/issue/58/false-positive-no-member-on-numpy-imports

我建议禁用投诉发生的线路。

# pylint: disable=E1103
print np.zeros([1, 4])
# pylint: enable=E1103

There have been many different bugs reported about this over the past few years i.e. https://bitbucket.org/logilab/pylint/issue/58/false-positive-no-member-on-numpy-imports

I’d suggest disabling for the lines where the complaints occur.

# pylint: disable=E1103
print np.zeros([1, 4])
# pylint: enable=E1103

回答 8

可能是,它与numpy的方法导入的抽象方法混淆了。也就是说,zeros实际上numpy.core.multiarray.zeros是通过numpy语句导入的

from .core import *

依次导入

from .numeric import *

并且以数字形式您会发现

zeros = multiarray.zeros

我想我会代替PyLint感到困惑!

有关PyLint侧面的信息,请参见此错误

Probably, it’s confused with numpy’s abstruse method of methods import. Namely, zeros is in fact numpy.core.multiarray.zeros, imported in numpy with statement

from .core import *

in turn imported with

from .numeric import *

and in numeric you’ll find

zeros = multiarray.zeros

I guess I would be confused in place of PyLint!

See this bug for PyLint side of view.


回答 9

我必须将其添加到我经常使用numpy的任何文件的顶部。

# To ignore numpy errors:
#     pylint: disable=E1101

以防万一有人在日食中遇到Pydev和pylint的麻烦…

I had to add this at the top of any file where I use numpy a lot.

# To ignore numpy errors:
#     pylint: disable=E1101

Just in case someone in eclipse is having trouble with Pydev and pylint…


回答 10

在j_hougs答案的扩展中,您现在可以在.pylintrc的此行中添加有问题的模块,该行在生成时已经准备好为空:

extension-pkg-whitelist=numpy

您可以通过执行以下操作来生成示例.pylintrc:

pylint --generate-rcfile > .pylintrc

然后编辑提到的行

In Extension to j_hougs answer, you can now add the modules in question to this line in .pylintrc, which is already prepared empty on generation:

extension-pkg-whitelist=numpy

you can generate a sample .pylintrc by doing:

pylint --generate-rcfile > .pylintrc

and then edit the mentioned line


回答 11

终于在Pylint 1.8.2中解决了这个问题。开箱即用,无需pylintrc调整!

This has finally been resolved in Pylint 1.8.2. Works out of the box, no pylintrc tweaks needed!


回答 12

这是我针对此问题提出的伪解决方案。

#pylint: disable=no-name-in-module
from numpy import array as np_array, transpose as np_transpose, \
      linspace as np_linspace, zeros as np_zeros
from numpy.random import uniform as random_uniform
#pylint: enable=no-name-in-module

然后,在你的代码,而不是调用numpy功能np.arraynp.zeros等等,你会写np_arraynp_zeros等等。这种做法与在其他的答案提出其他方法的优点:

  • pylint禁用/启用仅限于代码的一小部分
  • 这意味着您不必用pylint指令将每一个调用numpy函数的行都包围起来。
  • 您没有为整个文件执行pylint禁用错误操作,这可能会掩盖代码的其他问题。

明显的缺点是,您必须显式导入您使用的每个numpy函数。该方法可以进一步阐述。您可以定义自己的模块,numpy_importer如下所示

""" module: numpy_importer.py
       explicitely import numpy functions while avoiding pylint errors  
"""
#pylint: disable=unused-import
#pylint: disable=no-name-in-module
from numpy import array, transpose, zeros  #add all things you need  
from numpy.random import uniform as random_uniform
#pylint: enable=no-name-in-module

然后,您的应用程序代码只能将该模块(而不是numpy)导入为

import numpy_importer as np 

并像往常一样使用名称:np.zerosnp.array等等。

这样做的好处是您将拥有一个模块,其中所有numpy相关的导入都将一劳永逸地完成,然后您可以在任意位置使用该行导入它。仍然要注意numpy_importer不要导入不存在的名称,numpy因为这些错误不会被pylint捕获。

This is the pseudo-solution I have come up with for this problem.

#pylint: disable=no-name-in-module
from numpy import array as np_array, transpose as np_transpose, \
      linspace as np_linspace, zeros as np_zeros
from numpy.random import uniform as random_uniform
#pylint: enable=no-name-in-module

Then, in your code, instead of calling numpy functions as np.array and np.zeros and so on, you would write np_array, np_zeros, etc. Advantages of this approach vs. other approaches suggested in other answers:

  • The pylint disable/enable is restricted to a small region of your code
  • That means that you don’t have to surround every single line that has an invocation of a numpy function with a pylint directive.
  • You are not doing pylint disable of the error for your whole file, which might mask other issues with your code.

The clear disadvantage is that you have to explicitely import every numpy function you use. The approach could be elaborated on further. You could define your own module, call it say, numpy_importer as follows

""" module: numpy_importer.py
       explicitely import numpy functions while avoiding pylint errors  
"""
#pylint: disable=unused-import
#pylint: disable=no-name-in-module
from numpy import array, transpose, zeros  #add all things you need  
from numpy.random import uniform as random_uniform
#pylint: enable=no-name-in-module

Then, your application code could import this module only (instead of numpy) as

import numpy_importer as np 

and use the names as usual: np.zeros, np.array etc.

The advantage of this is that you will have a single module in which all numpy related imports are done once and for all, and then you import it with that single line, wherever you want. Still you have to be careful that numpy_importer does not import names that don´t exist in numpy as those errors won’t be caught by pylint.


回答 13

我遇到了numpy,scipy,sklearn,nipy等问题,并通过包裹epylint来解决了这个问题,如下所示:

$猫epylint.py

#!/usr/bin/python

"""
Synopsis: epylint wrapper that filters a bunch of false-positive warnings and errors
Author: DOHMATOB Elvis Dopgima <gmdopp@gmail.com> <elvis.dohmatob@inria.fr>

"""

import os
import sys
import re
from subprocess import Popen, STDOUT, PIPE

NUMPY_HAS_NO_MEMBER = re.compile("Module 'numpy(?:\..+)?' has no '.+' member")
SCIPY_HAS_NO_MEMBER = re.compile("Module 'scipy(?:\..+)?' has no '.+' member")
SCIPY_HAS_NO_MEMBER2 = re.compile("No name '.+' in module 'scipy(?:\..+)?'")
NIPY_HAS_NO_MEMBER = re.compile("Module 'nipy(?:\..+)?' has no '.+' member")
SK_ATTR_DEFINED_OUTSIDE_INIT = re.compile("Attribute '.+_' defined outside __init__")
REL_IMPORT_SHOULD_BE = re.compile("Relative import '.+', should be '.+")
REDEFINING_NAME_FROM_OUTER_SCOPE = re.compile("Redefining name '.+' from outer scope")

if __name__ == "__main__":
    basename = os.path.basename(sys.argv[1])
    for line in Popen(['epylint', sys.argv[1], '--disable=C,R,I'  # filter thesew arnings
                       ], stdout=PIPE, stderr=STDOUT, universal_newlines=True).stdout:
        if line.startswith("***********"):
            continue
        elif line.startswith("No config file found,"):
            continue
        elif "anomalous-backslash-in-string," in line:
            continue
        if NUMPY_HAS_NO_MEMBER.search(line):
            continue
        if SCIPY_HAS_NO_MEMBER.search(line):
            continue
        if SCIPY_HAS_NO_MEMBER2.search(line):
            continue
        if "Used * or ** magic" in line:
            continue
        if "No module named" in line and "_flymake" in line:
            continue
        if SK_ATTR_DEFINED_OUTSIDE_INIT.search(line):
            continue
        if "Access to a protected member" in line:
            continue
        if REL_IMPORT_SHOULD_BE.search(line):
            continue
        if REDEFINING_NAME_FROM_OUTER_SCOPE.search(line):
            continue
        if NIPY_HAS_NO_MEMBER.search(line):
            continue
        # XXX extend by adding more handles for false-positives here
        else:
            print line,

该脚本仅运行epylint,然后刮擦其输出以过滤掉错误肯定的警告和错误。您可以通过添加更多elif案例来扩展它。

注意:如果这适用于您,则您需要修改pychechers.sh,使其像这样

#!/bin/bash

epylint.py "$1" 2>/dev/null
pyflakes "$1"
pep8 --ignore=E221,E701,E202 --repeat "$1"
true

(当然,您必须首先使epylint.py可执行)

这是我的.emacs https://github.com/dohmatob/mydotemacs的链接。希望这对某人有用。

I had this problem with numpy, scipy, sklearn, nipy, etc., and I solved it by wrapping epylint like so:

$ cat epylint.py

#!/usr/bin/python

"""
Synopsis: epylint wrapper that filters a bunch of false-positive warnings and errors
Author: DOHMATOB Elvis Dopgima <gmdopp@gmail.com> <elvis.dohmatob@inria.fr>

"""

import os
import sys
import re
from subprocess import Popen, STDOUT, PIPE

NUMPY_HAS_NO_MEMBER = re.compile("Module 'numpy(?:\..+)?' has no '.+' member")
SCIPY_HAS_NO_MEMBER = re.compile("Module 'scipy(?:\..+)?' has no '.+' member")
SCIPY_HAS_NO_MEMBER2 = re.compile("No name '.+' in module 'scipy(?:\..+)?'")
NIPY_HAS_NO_MEMBER = re.compile("Module 'nipy(?:\..+)?' has no '.+' member")
SK_ATTR_DEFINED_OUTSIDE_INIT = re.compile("Attribute '.+_' defined outside __init__")
REL_IMPORT_SHOULD_BE = re.compile("Relative import '.+', should be '.+")
REDEFINING_NAME_FROM_OUTER_SCOPE = re.compile("Redefining name '.+' from outer scope")

if __name__ == "__main__":
    basename = os.path.basename(sys.argv[1])
    for line in Popen(['epylint', sys.argv[1], '--disable=C,R,I'  # filter thesew arnings
                       ], stdout=PIPE, stderr=STDOUT, universal_newlines=True).stdout:
        if line.startswith("***********"):
            continue
        elif line.startswith("No config file found,"):
            continue
        elif "anomalous-backslash-in-string," in line:
            continue
        if NUMPY_HAS_NO_MEMBER.search(line):
            continue
        if SCIPY_HAS_NO_MEMBER.search(line):
            continue
        if SCIPY_HAS_NO_MEMBER2.search(line):
            continue
        if "Used * or ** magic" in line:
            continue
        if "No module named" in line and "_flymake" in line:
            continue
        if SK_ATTR_DEFINED_OUTSIDE_INIT.search(line):
            continue
        if "Access to a protected member" in line:
            continue
        if REL_IMPORT_SHOULD_BE.search(line):
            continue
        if REDEFINING_NAME_FROM_OUTER_SCOPE.search(line):
            continue
        if NIPY_HAS_NO_MEMBER.search(line):
            continue
        # XXX extend by adding more handles for false-positives here
        else:
            print line,

This script simply runs epylint, then scrapes its output to filter out false-positive warnings and errors. You can extend it by added more elif cases.

N.B.: If this applies to you, then you’ll want to modify your pychechers.sh so it likes like this

#!/bin/bash

epylint.py "$1" 2>/dev/null
pyflakes "$1"
pep8 --ignore=E221,E701,E202 --repeat "$1"
true

(Of course, you have to make epylint.py executable first)

Here is a link to my .emacs https://github.com/dohmatob/mydotemacs. Hope this is useful to someone.


回答 14

这似乎至少在Pylint 1.1.0上有效:

[TYPECHECK]

ignored-classes=numpy

This seems to work on at least Pylint 1.1.0:

[TYPECHECK]

ignored-classes=numpy

回答 15

这个解决方案对我有用

基本上,请从左下角选择齿轮图标=> Setting => Workspace Setting => Extension => Python Configuration =>单击任何Settings.json =>将此添加到文件“ python.linting.pylintArgs”中:[ –extension-pkg-whitelist = numpy“]我正在使用VS 1.27.2

This solution worked for me

Basically, go to Select the gear icon from bottom left=>Setting=>Workspace Setting =>Extension=>Python Configuration=>Click on any Settings.json => add this in the file “python.linting.pylintArgs” : [ “–extension-pkg-whitelist=numpy” ] I am using VS 1.27.2


回答 16

我在另一个不同的模块(kivy.properties)上遇到了同样的问题,它是一个包装好的C模块,例如numpy

使用VSCode V1.38.0,公认的解决方案停止了该项目的所有棉绒。因此,尽管它确实消除了误报no-name-in-module,但并没有真正改善这种情况。

对我来说,最好的解决方法是--ignored-modules在有问题的模块上使用参数。麻烦的是,通过传递任何参数python.linting.pylintArgs抹了默认VSCode设置,所以你需要重新设置者也。那给我留下了以下settings.json文件:

{
    "python.pythonPath": "C:\\Python\\Python37\\python.exe",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "python.linting.pylintArgs": [
        "--ignored-modules=kivy.properties",
        "--disable=all",
        "--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode"
    ]
}

I had the same problem with a different module (kivy.properties) which is a wrapped C module like numpy.

Using VSCode V1.38.0, the accepted solution stopped all linting for the project. So, while it did indeed remove the false-positive no-name-in-module, it didn’t really improve the situation.

The best workaround for me was to use the --ignored-modules argument on the offending module. Trouble is, passing any argument via python.linting.pylintArgs wipes out the default VSCode settings, so you need to re-set those also. That left me with the following settings.json file:

{
    "python.pythonPath": "C:\\Python\\Python37\\python.exe",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "python.linting.pylintArgs": [
        "--ignored-modules=kivy.properties",
        "--disable=all",
        "--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode"
    ]
}

回答 17

从前面的答案中复制了一些文字,以总结出有效的方法(至少对我来说:debian-jessie)

  1. 在某些旧版本中,pylint存在一个问题,使其无法与numpy(及其他类似软件包)一起使用。

  2. 现在已经解决了该问题,但是出于安全原因,默认情况下禁用了外部C包(C代码的python接口-例如numpy-)。

  3. 您可以创建白名单,以允许pylint在文件中使用它们~/.pylintrc

要运行的基本命令:#仅在您家中没有.pylintrc文件的情况下$ pylint –generate-rcfile> .pylintrc

然后打开文件并添加所需的软件包(extension-pkg-whitelist=用逗号分隔)。使用--extension-pkg-whitelist=numpy命令行中的选项,您可以具有相同的行为。

如果您忽略了本[TYPECHECK]节中的某些软件包,则这pylint将永远不会显示与该软件包相关的错误。实际上,pylint不会告诉您有关那些软件包的任何信息。

A little bit of copy paste from the previous answer to summarize what is working (at least for me: debian-jessie)

  1. In some older version of pylint there was a problem preventing it working with numpy (and other similar packages).

  2. Now that problem has been solved but external C packages (python interfaces to C code -like numpy-) are disabled by default for security reasons.

  3. You can create a white list, to allow pylint to use them in the file ~/.pylintrc.

Basic command to run: # ONLY if you do not already have a .pylintrc file in your home $ pylint –generate-rcfile > .pylintrc

Then open the file and add the packages you want after extension-pkg-whitelist= separated by comma. You can have the same behavior using the option --extension-pkg-whitelist=numpy from the command line.

If you ignore some packages in the [TYPECHECK] section that means that pylint will never show error related to that packages. In practice, pylint will not tell you anything about those packages.


回答 18

我一直在为pylint制作补丁,以解决numpy等库中动态成员的问题。它添加了一个“动态模块”选项,该选项通过实际导入模块来强制检查运行时是否存在成员。请参阅logilab / pylint中的第413期。还有一个拉取请求,请参阅注释之一中的链接。

I’ve been working on a patch to pylint to solve the issue with dynamic members in libraries such as numpy. It adds a “dynamic-modules” option which forces to check if members exist during runtime by making a real import of the module. See Issue #413 in logilab/pylint. There is also a pull request, see link in one of the comments.


回答 19

快速答案:将Pylint更新为1.7.1(如果使用conda管理软件包,请使用conda-forge提供的Pylint 1.7.1)

我在此处的pylint GitHub中发现了类似的问题,有人回复说更新到1.7.1后一切正常。

A quick answer: update Pylint to 1.7.1 (use conda-forge provided Pylint 1.7.1 if you use conda to manage packages)

I found a similar issue in pylint GitHub here and someone replied everything getting OK after updating to 1.7.1.


回答 20

我不确定这是否是解决方案,但是在VSCode中,我在用户设置中明确编写了启用pylint的代码后,所有模块都被识别。

{
    "python.linting.pep8Enabled": true,
    "python.linting.pylintEnabled": true
}

I’m not sure if this is a solution, but in VSCode once I wrote explicitly in my user settings to enable pylint, all modules were recognized.

{
    "python.linting.pep8Enabled": true,
    "python.linting.pylintEnabled": true
}

回答 21

最近(由于spyder或pylint或?有所更改),我从astropy.constants符号的spyder静态代码分析中得到了E1101错误(“无成员”)。不知道为什么。

对于Linux或Unix系统(Mac可能与此类似)上的所有用户,我的简化解决方案是创建一个/ etc / pylintrc,如下所示:

[TYPECHECK]
ignored-modules=astropy.constants

当然,可以将其放在个人$ HOME / .pylintrc文件中。而且,我本可以更新现有文件。

Lately (since something changed in spyder or pylint or ?), I have been getting E1101 errors (“no member”) from spyder’s static code analysis on astropy.constants symbols. No idea why.

My simplistic solution for all users on a Linux or Unix system (Mac is probably similar) is to create an /etc/pylintrc as follows:

[TYPECHECK]
ignored-modules=astropy.constants

Of course, this could, instead, be put in a personal $HOME/.pylintrc file. And, I could have updated an existing file.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。