我正在Python项目上运行Pylint。Pylint多次抱怨找不到NumPy成员。我如何避免这种情况,同时避免跳过成员资格检查?
从代码中:
import numpy as np
print np.zeros([1, 4])
当运行时,我得到了预期的结果:
[ 0.0。0。0。]
然而,Pylint给了我这个错误:
E: 3,6:模块'numpy‘没有’零‘成员(无成员)
对于版本,我使用Pylint 1.0.0 (astroid 1.0.1,common 0.60.0),并尝试使用NumPy 1.8.0。
发布于 2016-09-15 06:43:10
如果将Visual Studio Code与Don Jayamanne的优秀Python extension一起使用,请将用户设置添加到白名单NumPy:
{
// Whitelist NumPy to remove lint errors
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=numpy"
]
}
发布于 2015-01-14 20:50:17
我在这里遇到了同样的问题,即使是所有相关包的最新版本(astroid 1.3.2
、logilab_common 0.63.2
、pylon 1.4.0
)也是如此。
下面的解决方案非常好用:我在[TYPECHECK]
部分修改了我的pylintrc
文件,将numpy
添加到了被忽略的模块列表中:
[TYPECHECK]
ignored-modules = numpy
根据错误,您可能还需要添加以下行(仍在[TYPECHECK] section
中):
ignored-classes = numpy
发布于 2016-02-08 06:29:20
我在一个正在处理的小型NumPy项目中遇到了同样的错误,并决定忽略NumPy模块就可以了。我创建了一个包含以下内容的.pylintrc
文件:
$ pylint --generate-rcfile > ~/.pylintrc
遵循paduwan's和j_houg's的建议,我修改了以下部分:
[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
它“修复”了我的问题。
https://stackoverflow.com/questions/20553551
复制相似问题