A newbie question. I am trying to get pythonVSCode working with a venv virtual environment for Python 3.6 on a Mac.
Following the documentation, I activated the virtual environment and launched VSCode from the terminal.
When VSCode suggested installing pylint, I tried using the pythonVSCode's "Install" button that came with the suggestion, but that threw an error in VSCode's terminal:
/usr/bin/python -m pip install pylint
$ /usr/bin/python -m pip install pylint
/usr/bin/python: No module named pip
I then installed pylint via the system (not VSCode's) terminal and within the virtual environment:
(venv) $ pip install pylint
... and re-launched VSCode from the terminal.
VSCode still suggests installing pylint.
I suspect this has something to do with paths. I expected launching VSCode from within the virtual environment will load that environment's interpreter including pylint in VSCode, but it seems not to be the case.
Open Visual Studio Code in your project's folder. Click Yes ; and your venv is ready to go. Open a new terminal within VSCode Ctrl + Shift + P and you'll see that venv is getting picked up; e.g.: (venv) ... Activate.
venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation.
A virtual environment is a directory tree which contains Python executable files and other files which indicate that it is a virtual environment. Common installation tools such as setuptools and pip work as expected with virtual environments.
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
You are right, it's about paths. You should have something like this in your settings.json file:
{
"python.pythonPath": "your_project_path/your_venv/Scripts/python",
"python.linting.pylintPath": "your_project_path/your_venv/Scripts/pylint"
}
I had the same problem as of 07/2018.
Solution: activate your virtualenv:
source yourenv/bin/activate
in the terminal with the active virtualenv, do the following:
Install pylint in your virtualenv:
(yourenv) user@machine/your/env/folder$ pip install pylint
Open VSCODE from the terminal, inside your virtualenv, using the "code" command. Let open only the new VSCode instance.
(yourenv) user@machine/your/env/folder$ code
Have fun coding using pylint.
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