Home >Backend Development >Python Tutorial >How to Fix PyLint\'s \'Unable to Import\' Error: A PYTHONPATH Resolution
Remedying PyLint's "Unable to Import" Error: A PYTHONPATH Fix
When executing PyLint from within the Wing IDE on Windows, one may encounter the perplexing "Unable to import" error while attempting to import a module from a different directory within the project. To rectify this issue, consider the following solutions:
Option 1: Modifying the PYTHONPATH Environment Variable
Adjust the PYTHONPATH environment variable to incorporate the directory containing the root of your module. This will ensure that PyLint has access to the necessary modules during its execution.
Option 2: Editing ~/.pylintrc
Alternatively, modify the ~/.pylintrc file to include the directory located above your module. Add the following line under the [MASTER] section (or [General] in certain PyLint versions):
init-hook='import sys; sys.path.append("/path/to/root")'
By implementing either of these options, you should effectively resolve the import errors encountered while using PyLint.
The above is the detailed content of How to Fix PyLint\'s \'Unable to Import\' Error: A PYTHONPATH Resolution. For more information, please follow other related articles on the PHP Chinese website!