Search code examples
pythonvisual-studio-codepylint

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


Solution

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

    PYTHONPATH=./src