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 .
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
I had this problem with numpy, scipy, sklearn, nipy, etc., and I solved it by wrapping epylint like so:
$ cat epylint.py
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
(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.
If using Visual Studio Code with Don Jayamanne's excellent Python extension, add a user setting to whitelist 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 mypylintrc
file, in the[TYPECHECK]
section:Depending on the error, you might also need to add the following line (still in the
[TYPECHECK] section
):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.
This seems to work on at least Pylint 1.1.0: