{"id":1141,"hash":"01b54932e7661136d5dfe2dfe7b15ef1749fdb4fe943dde5cdfb0c909a6b6e61","pattern":"PyLint &quot;Unable to import&quot; error - how to set PYTHONPATH?","full_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.\n\n__init__.py\nmyapp.py\none.py\nsubdir\\\n    __init__.py\n    two.py\n\nInside 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:\n\nF0401: Unable to import 'one'\n\nHow do I fix this?","ecosystem":"pypi","package_name":"virtualenv","package_version":null,"solution":"There are two options I'm aware of.\n\nOne, change the PYTHONPATH environment variable to include the directory above your module.\n\nAlternatively, edit ~/.pylintrc to include the directory above your module, like this:\n\n[MASTER]\ninit-hook='import sys; sys.path.append(\"/path/to/root\")'\n\n(Or in other version of pylint, the init-hook requires you to change [General] to [MASTER])\n\nBoth of these options ought to work.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/1899436/pylint-unable-to-import-error-how-to-set-pythonpath","votes":345,"created_at":"2026-04-19T04:52:25.788169+00:00","updated_at":"2026-04-19T04:52:25.788169+00:00"}