I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie.
__init__.py
myapp.py
one.py
subdir\
__init__.py
two.py
Inside two.py
I have import one
and this works fine at runtime, because the top-level directory (from which myapp.py
is run) is in the Python path. However, when I run PyLint on two.py it gives me an error:
F0401: Unable to import 'one'
How do I fix this?
There are two options I'm aware of.
One, change the PYTHONPATH
environment variable to include the directory above your module.
Alternatively, edit ~/.pylintrc
to include the directory above your module, like this:
[MASTER]
init-hook='import sys; sys.path.append("/path/to/root")'
(Or in other version of pylint, the init-hook requires you to change [General] to [MASTER])
Both of these options ought to work.
Hope that helps.