Environment data
- VS Code version: 1.24.1
- Extension version (available under the Extensions sidebar): 2018.5.0
- OS and version: Ubuntu 14.04
- Python version: 2.7.6
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
Actual behavior
When using the "Go to definition" feature (eg F12) on the name of an imported library, the priority of the lookup seems to be made on libraries installed in ~/.local, even if the library is also installed in the virtual environment configured for the current project.
It seems to be the case only if the lib is installed in ~/.local (ie pip install --user mode).
If the library was not installed in --user mode (ie in something like /usr/local/lib/(...), then the library from the virtualenv is correctly used.
Please note that it does not impact feature Run Python File in Terminal which uses the virtualenv library, as it should.
Expected behavior
The lookup priority of the "Go to definition" feature should be the same as the sys.path of virtualenv's python.
In other terms, it should go to the definition of the lib installed in the virtualenv.
Steps to reproduce:
- Create a new project containing one python file, which contains only:
import pytest
- Create a new virtual environment, and install pytest in it:
virtualenv /tmp/temp_venv
source /tmp/temp_venv/bin/activate
pip install pytest
- Configure the project
settings.json so that it uses the virtualenv
"python.pythonPath": "/tmp/temp_venv/bin/python"
- Go to the project file, and try to go to the definition of
pytest in import pytest
--> /tmp/temp_venv/lib/python2.7/site-packages/pytest.py is opened, which is OK
- Install pytest system wide, outside the virtualenv
sudo pip install pytest
- Go to the project file, and try to go to the definition of
pytest in import pytest
--> /tmp/temp_venv/lib/python2.7/site-packages/pytest.py is opened, which is OK
- Install pytest in user's home, outside the virtualenv
pip install pytest --user
- Go to the project file, and try to go to the definition of
pytest in import pytest
--> ~/.local/lib/python2.7/site-packages/pytest.py is opened, which is KO
Environment data
Actual behavior
When using the "Go to definition" feature (eg F12) on the name of an imported library, the priority of the lookup seems to be made on libraries installed in
~/.local, even if the library is also installed in the virtual environment configured for the current project.It seems to be the case only if the lib is installed in
~/.local(iepip install --usermode).If the library was not installed in
--usermode (ie in something like/usr/local/lib/(...), then the library from the virtualenv is correctly used.Please note that it does not impact feature
Run Python File in Terminalwhich uses the virtualenv library, as it should.Expected behavior
The lookup priority of the "Go to definition" feature should be the same as the
sys.pathof virtualenv's python.In other terms, it should go to the definition of the lib installed in the virtualenv.
Steps to reproduce:
import pytestvirtualenv /tmp/temp_venvsource /tmp/temp_venv/bin/activatepip install pytestsettings.jsonso that it uses the virtualenv"python.pythonPath": "/tmp/temp_venv/bin/python"pytestinimport pytest-->
/tmp/temp_venv/lib/python2.7/site-packages/pytest.pyis opened, which is OKsudo pip install pytestpytestinimport pytest-->
/tmp/temp_venv/lib/python2.7/site-packages/pytest.pyis opened, which is OKpip install pytest --userpytestinimport pytest-->
~/.local/lib/python2.7/site-packages/pytest.pyis opened, which is KO