Home >Backend Development >Python Tutorial >How to Resolve PyLint \'Unable to Import\' Error by Modifying PYTHONPATH?
Resolving PyLint "Unable to Import" Error by Modifying PYTHONPATH
When utilizing PyLint within Wing IDE on Windows, importing modules from subdirectories within a project can trigger the error "Unable to import 'X'." This error occurs because PyLint's default Python path does not include the project's root directory, where the top-level module is located.
To rectify this issue, two options are available:
1. Adjusting PYTHONPATH Environment Variable
2. Modifying ~/.pylintrc File
init-hook='import sys; sys.path.append("/path/to/root")'
Either of these methods should successfully resolve the "Unable to import" error by adding the necessary directories to PyLint's Python path, ensuring that it can locate and import modules as expected.
The above is the detailed content of How to Resolve PyLint \'Unable to Import\' Error by Modifying PYTHONPATH?. For more information, please follow other related articles on the PHP Chinese website!