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 .
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:
and
and it "fixed" my issue.
I had to add this at the top of any file where I use numpy a lot.
Just in case someone in eclipse is having trouble with Pydev and 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.This has finally been resolved in Pylint 1.8.2. Works out of the box, no pylintrc tweaks needed!
Probably, it's confused with numpy's abstruse method of methods import. Namely,
zeros
is in factnumpy.core.multiarray.zeros
, imported in numpy with statementin turn imported with
and in numeric you'll find
I guess I would be confused in place of PyLint!
See this bug for PyLint side of view.
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.