pypivirtualenv95% confidence\u2191 345

PyLint "Unable to import" error - how to set PYTHONPATH?

Full error message
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.

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/01b54932e7661136d5dfe2dfe7b15ef1749fdb4fe943dde5cdfb0c909a6b6e61
hash \u00b7 01b54932e7661136d5dfe2dfe7b15ef1749fdb4fe943dde5cdfb0c909a6b6e61
PyLint "Unable to import" error - how to set PYTHO… — DepScope fix | DepScope