I have a project with that structure:
├── .git
├── .gitignore
├── README.md
├── requirements.txt
└── src
Pylint by default running from project root and I have error on all my imports, because source root in src
directory.
I try to setup the linter path in settings.json, but then linter don't work
"python.linting.pylintPath": "cd src && pylint"
Question is: how to change the source root for pylint in VS Code? I use this extension https://github.com/DonJayamanne/pythonVSCode
To do so, open the Command Palette (Ctrl+Shift+P) and enter Preferences: Open User Settings. Then set python.condaPath , which is in the Python extension section of User Settings, with the appropriate path.
Add this line in your settings.json
file (in the .vscode
directory).
"python.autoComplete.extraPaths": ["./src"],
You can solve this by creating a .env
file in the project root with content:
PYTHONPATH=./src
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With