Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup working directory in VS Code for pylint?

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

like image 522
Artyom Chebotaryov Avatar asked Nov 03 '17 09:11

Artyom Chebotaryov


People also ask

How do I change the Python directory in Visual Studio Code?

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.


2 Answers

Add this line in your settings.json file (in the .vscode directory).

"python.autoComplete.extraPaths": ["./src"],
like image 52
Marco Lavagnino Avatar answered Sep 20 '22 01:09

Marco Lavagnino


You can solve this by creating a .env file in the project root with content:

PYTHONPATH=./src
like image 42
Artyom Chebotaryov Avatar answered Sep 20 '22 01:09

Artyom Chebotaryov