-
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
Cannot run or debug python files: An Invalid Python interpreter is selected #23878
Comments
Thanks for the bug report, what is the value that is shown for the interpreter in the bottom right bar? |
Thanks for your reply, it looks like an error in how the Python Extension select the interpreter, for some reason it is not taking your path as valid. Sending back to the Python Extension. |
Hello @Nika-St Thank you for filing the issue. Python in the Output panel (View →Output , change the drop-down the upper-right of the Output panel to Python )
Would love to dig into this further. Thanks. |
Hi @anthonykim1 , thanks for responding! Now I'm away for a few weeks, will comment as soon as I'm back! |
@YaoJusheng Are you also on a remote scenario? Can you guys add:
in your settings.json and see if you can repro the same problem? Also try search for the native locator setting and change it to js instead of native and give that a try if above doesn't work. |
Thanks for the reply. It is not a remote scenario. I created a new virtual environment $ pyenv versions --skip-aliases
system
* 3.8.12 (set by /Users/yaojusheng/.pyenv/version)
3.10.12
pypy3.10-7.3.16
$ ~/.pyenv/versions/3.10.12/bin/python -m venv ~/CodeSpace/.venv/test-3.10.12 But when I copy the python interpreter under pyenv to the virtual environment, it appears that python can be recognized as $ rm ~/CodeSpace/.venv/test-3.10.12/bin/python
$ cp ~/.pyenv/versions/3.10.12/bin/python ~/CodeSpace/.venv/test-3.10.12/bin After selecting, Output -> Python:
If select python3, it will be recognized as After selecting, Output -> Python:
This is really weird, it can't seem to find the correct location automatically. |
@Nika-St Can you try modifying '{"python.defaultInterpreterPath": "/bin/python",}' to point to absolute path to your Python rather than relative? |
@YaoJusheng Thanks for the input here.
|
I am currently facing the same issue. I have cloned repo from my GitHub to my laptop and whenever i activate venv i have created on my PC the interpreter does not change to .\venv\Scripts\python.exe When I select it manually I recieve an error "An Invalid Python interpreter is seleceted" Output:
Same thing happens when setting "python.defaultInterpreterPath" to absolute path of venv's python.exe |
@Ha-Yen Does relative path (in workspace stand point) to your venv work? |
Thanks for your reply @anthonykim1 ! |
Neither did this: I actually have the absolute path there, just didn't post the complete text here |
This shows: 2024-09-17 16:18:51.768 [info] > [path to venv]/bin/python -I ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py
code: 127, And also this: 2024-09-17 16:16:55.612 [info] Found: [path to venv]/bin/python3.11 --> [path]/python/Python-3.11.9.build/bin/python3.11
code: 2,
code: 126,
code: 1, |
Yeah venv was pointing out to absolute path. I have changed to relative but interpreter was still not working. Only work around I have found is excluding venv from git. Creating requirements.txt and creating new venv on other machine where I used requirements.txt to install all packages that were installed in original venv. |
Hi @anthonykim1, any updates? :) |
Interesting... @Nika-St Have you tried to venv path setting? ![]() |
@anthonykim1 , oh I have... |
I see.. I cannot repro this -
Is your .../python a directory? because python extension is expecting an executable
I'm not sure where this [path to venv] is coming from. From extension standpoint its the file "src/client/pythonEnvironments/base/locators/composite/envsResolver.ts" but I do not see [path to venv] coming from extension. |
@anthonykim1 , just to disambiguate: It shouldn't even look under /usr/lib64/python, because I created the venv off of a python version installed for my user, and not globally, and the path to it is set wherever available: I have path to venv in Python: Venv Path is defined on the remote, |
Tried unsuccessfully: |
What's incorrect @anthonykim1 ? |
Meaning "because I created the venv off of a python version installed for my user, and not globally, and the path to it is set wherever available:" is off in a way that is your "/h/[username]/venvs/cv/bin/python3" remains global. More common way of non-global environment would be per-workspace virtual environment where you would have virtual environment under your project workspace directory. |
Also is |
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off. Happy Coding! |
VS Code Version: 1.91.1
Local OS Version: Windows_NT x64 10.0.22631
Remote OS Version: SUSE Linux Enterprise Server (SLES) , version 15-SP3
I develop on a remote server using the VSCode extension:
Remote Development v0.25.0
Python extension: v2024.10.0
Python Debugger extension: v2024.8.0
I cannot run or debug python files. Keep getting the error:
"An Invalid Python interpreter is selected, please try changing it to enable features such as IntelliSense, linting, and debugging. See output for more details regarding why the interpreter is invalid."
Steps to Reproduce:
After selecting the path to my venv in the UI, the same outcome repeats over and over
The text was updated successfully, but these errors were encountered: