-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python.pythonPath doesn't work properly in workspace with multiple python projects #690
Comments
What do you mean by check the virtual env loaded? |
I'm sorry, probably not the best explanation! I mean that you must check the pythonPath used by VSC for the project relative to the .py file that you opened. So, if you open a .py file contained in the first project of your workspace, VSC uses the correct pythonPath, but if you open a .py contained in the second (or third, fourth, etc...) project of your workspace, VSC uses the pythonPath defined in the first project, not the one defined for the project that you are using. |
How are you identifying this issue? |
@DonJayamanne I've seen the same problem here, in my env. I'll try to clarify @pferretti explanation for you through a simple example:
mkvirtualenv -p /usr/bin/python3.6 project_1
mkvirtualenv -p /usr/bin/python3.6 project_2
settings.json from project_1{
"python.pythonPath": "/<your_root_folder>/project_1/bin/python"
} settings.json from project_2{
"python.pythonPath": "/<your_root_folder>/project_2/bin/python"
}
main.py from project_1print("Hello World!") main.py from project_2print("Hello World!")
Folder contents:project_1
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── activate_this.py
│ ├── easy_install
│ ├── easy_install-3.6
│ ├── epylint
│ ├── get_env_details
│ ├── isort
│ ├── pip
│ ├── pip3
│ ├── pip3.6
│ ├── postactivate
│ ├── postdeactivate
│ ├── preactivate
│ ├── predeactivate
│ ├── pylint
│ ├── pyreverse
│ ├── python -> python3.6
│ ├── python3 -> python3.6
│ ├── python3.6
│ ├── python-config
│ ├── symilar
│ └── wheel
├── include
│ └── python3.6m -> /usr/include/python3.6m
├── lib
│ └── python3.6
├── main.py
├── pip-selfcheck.json
└── .vscode
└── settings.json
project_2
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── activate_this.py
│ ├── easy_install
│ ├── easy_install-3.6
│ ├── epylint
│ ├── get_env_details
│ ├── isort
│ ├── pip
│ ├── pip3
│ ├── pip3.6
│ ├── postactivate
│ ├── postdeactivate
│ ├── preactivate
│ ├── predeactivate
│ ├── pylint
│ ├── pyreverse
│ ├── python -> python3.6
│ ├── python3 -> python3.6
│ ├── python3.6
│ ├── python-config
│ ├── symilar
│ └── wheel
├── include
│ └── python3.6m -> /usr/include/python3.6m
├── lib
│ └── python3.6
├── main.py
├── pip-selfcheck.json
└── .vscode
└── settings.json
6 - Open the As you can see above, it points to the python interpreter installed on 7 - Now open the See that the python interpreter used by this folder is the same as project_1, instead of project_2. Even if I try to click on that menu and try to change the python interpreter of project_2 folder, it not works, because the menu always point to project_1 folder. Check the bellow prints: I hope that I was clear enough. |
My vscode version is: 1.19.3-1516876437 |
I've tested with all of the bellow versions and the error occurs with all of them 1.19.3-1516876437 990
990 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
1.19.2-1515599945 990
990 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
1.19.1-1513676564 990
990 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
*** 1.19.0-1513245498 990
990 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
100 /var/lib/dpkg/status |
Thanks @galindro , a perfect explanation :-) |
Same here. Reproduces in 1.20. Makes vscode python extension almost unusable and results in false errors from all over the workspace. I had 9 folders in the same workspace and now I'm forced to remove and readd folders continuously to be able to use the extension. |
Sent here after filing the issue on the vscode repository. I would like to add that it doesn't necessarily have to be multiple Python projects, just any multi-root workspace. At least on Mac OS X 10.11.6. In my setup I have a two root folders in the workspace, one folder using Go and the other folder using Python. Only the Python folder has the EDIT: |
Same here. And I've done some work of debugging. The explanation is here (I filed the issue in vscode's repo by mistake 😂 |
@DonJayamanne is this fix already available for download/install? |
Well, I downloaded the latest source (master) and started it with vscode's |
@Tantalus13A98B5F Insiders Build of the python extension worked for me fully. Interpreter updates status bar correctly. I see the current folder's venv in venvs list. Not quite sure if all venvs are shown there. |
|
@DonJayamanne For me personally it's ok. I usually put the correct interpreter for the folder into its settings by hands. Explicit is better than implicit, you know:) |
@DonJayamanne is there an ETA for this fix be available to download/install? |
Just chiming in here that I also ran into this problem. I have a multi-project workspace that has a javascript project as well a python project. No matter what I do I cannot get the python project to select the interpreter since my javascript project is the first folder in the workspace. |
@lig @galindro @jkehler @Tantalus13A98B5F |
@DonJayamanne I've just noticed that installing |
Reproduces on the latest 2018.2.0-beta. |
@DonJayamanne is it already in Insiders Build? I'm eager to test it. Thanks! |
@lig Yes it is, please let me know how it goes |
@DonJayamanne no luck |
Could you point me on how can I check the exact installed extension's version and build? |
Unfortunately theres no way. Just uninstall and download, and re-install. |
What I did:
Expected result:
Actual result:
|
@lig I believe I know what's happened, our CI tests are failing hence the extension isn't getting built. Please test this build of the extension.
Apologies for this issue. Hopefully we'll have the CI tests resolved tomorrow (we've already got a PR lined up to resolve that) |
@DonJayamanne the last build you've provided here works as expected. Thank you! |
Environment data
VS Code version: 1.19.3
Python Extension version: 2018.1.0
Python Version: 3.6.4
OS and version: Ubuntu 16.04
Actual behavior
In a workspace with multiple projects associated to multiple virtual environments, the association with virtual environments doesn't work anymore. VSCode Python keep using the virtual environment defined in the first project of the workspace.
If I open the single projects, the association with virtual environment works as expected.
Expected behavior
Correct association to a proper virtual environment for every project in a workspace.
Steps to reproduce:
Logs
Output from
Python
output panelOutput from
Console window
(Help->Developer Tools menu)The text was updated successfully, but these errors were encountered: