Description
Environment data
VS Code version: 1.19.3
Python Extension version: 3.6.4
Python Version: 3
OS and version: MacOS High Sierra 10.13.3
Pipenv version 9.0.1 installed via brew install pipenv
Actual behavior
When I create a virtualenv via pipenv (using pipenv shell) everything works in Terminal. Specifically, which python
returns a path to python in the virtual env, e.g. /Users/tjaffri/.local/share/virtualenvs/hello-world-AxAtxCb5/bin/python
.
Next, I launch vscode from inside the virtualenv using code .
. I bring up the integrated terminal inside vscode and now it seems that vscode is not inheriting the virtualenv correctly. Specifically, which python
returns a path to the system python /usr/bin/python
.
Note that my vscode settings are completely empty (both workspace and user), so they are using default values for pythonPath etc.
When I try to do pipenv shell
inside the vscode integrated terminal, I get the following output indicating that the virtualenv is active (but for some reason the python being used is still the system python)
Taqis-MacBook-Pro:hello-world tjaffri$ pipenv shell
Shell for /Users/tjaffri/.local/share/virtualenvs/hello-world-AxAtxCb5 already activated.
No action taken to avoid nested environments.
When I run the script in the integrated terminal via python3 hello.py
(I have to use python3 rather than python due to the aforementioned issue) then there are problems with imported modules. Since the python3 being used is also the system python3 inside the integrated terminal, any modules installed via pipenv e.g. pipenv install beautifulsoup4
are not found and cannot be imported.
Note that when I run the same python3 hello.py
outside the integrated terminal, i.e. in the pipenv shell in Terminal everything works correctly.
Expected behavior
Pipenv created virtual environment should inherit into the vscode integrated terminal, when vscode is launched from inside a virtual environment.
Specifically, the python from inside the virtual environment should be used, so that imported modules in the virtual environment resolve correctly.
Steps to reproduce:
- Open Terminal
- mkdir hello-world
- cd hello-world
- pipenv install
- pipenv shell
- which python (note the result, this will be python inside the virtualenv)
- code .
- launch integrated terminal
- which python (note the result, this will be the system python)