0

I want to use a python environment with the following:

  1. A virtual environment.
  2. PYTHONPATH with local paths for development.
  3. Globally installed, linter-related packages--I don't want or need these in my virtual environment.

(1) is simple enough thanks to the docs.

"python.pythonPath": "<venv path>/bin/python",

I've handled (2) via adding it to an env file and my config:

"python.envFile": "${workspaceRoot}/.env"

The big problem is getting (1) and (3) together. Once (1) is set up, VSC starts complaining that it can't find the linters. The easy solution is update the linter paths:

    "python.linting.pylintPath": "/usr/local/bin/pylint",

Unfortunately, that means the linters cannot find the modules installed in the virtual environment.

The closest answer I've been able to find is this: Visual Studio Code - How to add multiple paths to python path?, but it still doesn't get to the root of the problem.

I'm coming from Atom, where this sort of thing just worked...ironic. I'm trying out VS Code 'cuz so many parts of Atom don't work smoothly.

muppetjones
  • 296
  • 3
  • 14

1 Answers1

0

I'm trying to achieve the same, use a globally installed pylint with my environment. I'm sure you saw this question where the answer says to run (the global) pylint using the virtualenv python by using python $(which pylint) instead of just pylint.

Since I didn't got it to work, I kept looking for a solution until I found this other question, basically it suggests that you break your requirements into a modular folder hierarchy like this:

    `-- django_project_root
    |-- requirements
    |   |-- common.txt
    |   |-- dev.txt
    |   `-- prod.txt
    `-- requirements.txt

Then you could place all linter-related dependencies on dev.txt and set it to import common requirements as well by adding -r common.txt.

I know it isn't exactly what you are looking for, but I think it's a good way to organize the requirements and to avoid having linter-related stuff in all environments.

Edit: I would also recommend you to see this link about managing multiple requirements files

leoschet
  • 1,697
  • 17
  • 33