Open Nika-St opened 3 months ago
Thanks for the bug report, what is the value that is shown for the interpreter in the bottom right bar?
Thanks for getting back, Paula! It shows 'Select Interpreter', and when I press on it, I only see the global python installations (not the locally installed one) and my venv set in "python.defaultInterpreterPath". When I select any of them, I get the error
|My venv, created off of the locally installed version, is active in terminal and runs without problems
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. Can you please post
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!
I ran into a similar but not identical problem.
After I create a virtual environment using the python version installed by pyenv:
~/.pyenv/versions/3.10.12/bin/python -m venv ~/Desktop/.venv/test-3.10.12
No matter how many times I select the virtual environment in the selector, it will eventually show that the path to the interpreter is the python version under pyenv, not the created virtual environment.
This is the print information:
This is quite frustrating, any suggestions on how to solve this problem?
@YaoJusheng Are you also on a remote scenario?
Can you guys add:
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],
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. Let me know if these things work out. Thanks
@YaoJusheng Are you also on a remote scenario?
Can you guys add:
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],
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. Let me know if these things work out. Thanks
Thanks for the reply. It is not a remote scenario. I created a new virtual environment test-3.10.12
.
After testing, I found that the same problem still exists.
$ 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 Venv
normally, and the virtual environment is loaded correctly.
$ 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:
2024-08-27 01:06:03.184 [info] Running installed packages checker: {
id: '/Users/yaojusheng/CodeSpace/.venv/test-3.10.12/bin/python',
sysPrefix: '/Users/yaojusheng/CodeSpace/.venv/test-3.10.12',
envType: 'Venv',
envName: 'test-3.10.12',
envPath: '/Users/yaojusheng/CodeSpace/.venv/test-3.10.12',
path: '/Users/yaojusheng/CodeSpace/.venv/test-3.10.12/bin/python',
architecture: 3,
sysVersion: '3.10.12 (main, Sep 23 2023, 04:09:33) [Clang 15.0.0 (clang-1500.0.40.1)]',
version: {
raw: '3.10.12',
major: 3,
minor: 10,
patch: 12,
build: [],
prerelease: [ 'final', '0' ]
},
displayName: "Python 3.10.12 ('test-3.10.12')",
detailedDisplayName: "Python 3.10.12 ('test-3.10.12': venv)",
type: 'Virtual'
}
If select python3, it will be recognized as Pyenv
, but the virtual environment will not be loaded correctly. Instead, it will be recognized as the python version under pyenv.
After selecting, Output -> Python:
2024-08-27 01:06:54.481 [info] Running installed packages checker: {
id: '/Users/yaojusheng/.pyenv/versions/3.10.12/bin/python3.10',
sysPrefix: '/Users/yaojusheng/.pyenv/versions/3.10.12',
envType: 'Pyenv',
envName: '3.10.12',
envPath: '/Users/yaojusheng/.pyenv/versions/3.10.12',
path: '/Users/yaojusheng/.pyenv/versions/3.10.12/bin/python3.10',
architecture: 3,
sysVersion: '3.10.12 (main, Sep 23 2023, 04:09:33) [Clang 15.0.0 (clang-1500.0.40.1)]',
version: {
raw: '3.10.12',
major: 3,
minor: 10,
patch: 12,
build: [],
prerelease: [ 'final', '0' ]
},
displayName: "Python 3.10.12 64-bit ('3.10.12')",
detailedDisplayName: "Python 3.10.12 64-bit ('3.10.12': pyenv)",
type: undefined
}
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:
Identifier for virt-virtualenv failed to identify ...\venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir '...\venv\Scripts'] {
errno: -4058,
code: 'ENOENT',
syscall: 'scandir',
path: '...\\venv\\Scripts'
}
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?
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],
Thanks for your reply @anthonykim1 ! This didn't change anything
@Nika-St Can you try modifying '{"python.defaultInterpreterPath": "/bin/python",}' to point to absolute path to your Python rather than relative?
Neither did this: I actually have the absolute path there, just didn't post the complete text here
Hello @Nika-St Thank you for filing the issue. Can you please post
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
) Would love to dig into this further. Thanks.
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 2024-09-17 16:18:51.770 [warning] Failed to check if [path to venv]/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '[path to venv]/bin/python'] { errno: -2, code: 'ENOENT', syscall: 'lstat', path: '[path to venv]/bin/python' } 2024-09-17 16:18:51.772 [warning] Failed to check if [path to venv]/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '[path to venv]/bin/python'] { errno: -2, code: 'ENOENT', syscall: 'lstat', path: '[path to venv]/bin/python' } 2024-09-17 16:18:51.772 [warning] Failed to check if [path to venv]/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '[path to venv]/bin/python'] { errno: -2, code: 'ENOENT', syscall: 'lstat', path: '[path to venv]/bin/python' } 2024-09-17 16:18:51.772 [error] Error: Command failed: [path to venv]/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py /bin/sh: [path to venv]/bin/python: No such file or directory
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at ChildProcess.exithandler (node:child_process:423:12)
at ChildProcess.emit (node:events:531:35)
at maybeClose (node:internal/child_process:1105:16)
at Socket.<anonymous> (node:internal/child_process:457:11)
at Socket.emit (node:events:519:28)
at Pipe.<anonymous> (node:net:338:12) {
code: 127, killed: false, signal: null, cmd: '[path to venv]/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py' }
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 2024-09-17 16:16:55.614 [info] Found: [path]/python/Python-3.11.9.build/bin/python3 --> [path]/python/Python-3.11.9.build/bin/python3.11 2024-09-17 16:16:55.614 [info] Found: [path]/python/Python-3.11.9.build/bin/python3.11 --> [path]/python/Python-3.11.9.build/bin/python3.11 2024-09-17 16:16:55.624 [info] Found: /usr/bin/X11/python --> /usr/bin/X11/python2.7 2024-09-17 16:16:55.624 [info] Found: /usr/bin/X11/python2 --> /usr/bin/X11/python2.7 2024-09-17 16:16:55.625 [info] Found: /usr/bin/X11/python2.7 --> /usr/bin/X11/python2.7 2024-09-17 16:16:55.626 [info] Found: /usr/bin/X11/python3 --> /usr/bin/X11/python3.4 2024-09-17 16:16:55.626 [info] Found: /usr/bin/X11/python3.4 --> /usr/bin/X11/python3.4 2024-09-17 16:16:55.649 [info] > /usr/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 2024-09-17 16:16:55.655 [warning] Error: Command failed: /usr/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py Unknown option: -I usage: /usr/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information.
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at ChildProcess.exithandler (node:child_process:423:12)
at ChildProcess.emit (node:events:531:35)
at maybeClose (node:internal/child_process:1105:16)
at Socket.<anonymous> (node:internal/child_process:457:11)
at Socket.emit (node:events:519:28)
at Pipe.<anonymous> (node:net:338:12) {
code: 2, killed: false, signal: null, cmd: '/usr/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py' } 2024-09-17 16:16:55.655 [error] Support for Python 2.7 has been dropped by the Python extension so certain features may not work, upgrade to using Python 3. 2024-09-17 16:16:55.668 [info] > /usr/bin/python ~/.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 2024-09-17 16:16:55.687 [info] > /usr/bin/python3 -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 2024-09-17 16:16:55.714 [info] > /usr/lib64/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 2024-09-17 16:16:55.724 [error] Error: Command failed: /usr/lib64/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py /bin/sh: /usr/lib64/python: Is a directory
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at ChildProcess.exithandler (node:child_process:423:12)
at ChildProcess.emit (node:events:531:35)
at maybeClose (node:internal/child_process:1105:16)
at Socket.<anonymous> (node:internal/child_process:457:11)
at Socket.emit (node:events:519:28)
at Pipe.<anonymous> (node:net:338:12) {
code: 126,
killed: false,
signal: null,
cmd: '/usr/lib64/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py'
}
2024-09-17 16:16:55.744 [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
2024-09-17 16:16:55.747 [error] Error: Command failed: [path to venv]/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py
[path to venv]/bin/python: /lib64/libm.so.6: version GLIBC_2.29' not found (required by [path to venv]/bin/python) [path to venv]/bin/python: /lib64/noelision/libpthread.so.0: version
GLIBC_2.30' not found (required by [path to venv]/bin/python)
[path to venv]/bin/python: /lib64/libc.so.6: version GLIBC_2.28' not found (required by [path to venv]/bin/python) [path to venv]/bin/python: /lib64/libc.so.6: version
GLIBC_2.25' not found (required by [path to venv]/bin/python)
[path to venv]/bin/python: /lib64/libc.so.6: version GLIBC_2.26' not found (required by [path to venv]/bin/python) [path to venv]/bin/python: /lib64/libc.so.6: version
GLIBC_2.27' not found (required by [path to venv]/bin/python)
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at ChildProcess.exithandler (node:child_process:423:12)
at ChildProcess.emit (node:events:531:35)
at maybeClose (node:internal/child_process:1105:16)
at Socket.<anonymous> (node:internal/child_process:457:11)
at Socket.emit (node:events:519:28)
at Pipe.<anonymous> (node:net:338:12) {
code: 1, killed: false, signal: null, cmd: '[path to venv]/bin/python -I [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/get_output_via_markers.py [path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py' } 2024-09-17 16:16:55.772 [info] Finished searching for interpreters in posix paths locator: 268 milliseconds
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 - Two things that remain suspicious to me are:
[path]/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/interpreterInfo.py
/bin/sh: /usr/lib64/python: Is a directory
Is your .../python a directory? because python extension is expecting an executable
2024-09-17 16:18:51.770 [warning] Failed to check if [path to venv]/bin/python is an executable [Error: ENOENT: no such file or directory, lstat '[path to venv]/bin/python'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '[path to venv]/bin/python'
}
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: [path] stands for my home dir, i. e. "/h/[username]" and [path to venv] stands for my venv, i. e. "/h/[username]/venvs/cv/bin/python3"
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.defaultInterpreterPath": "/h/[username]/venvs/cv/bin/python3", "python.pythonPath": "/h/[username]/venvs/cv/bin/python3", (looks deprecated) "python.venvPath": "/h/[username]/venvs/",
Python: Venv Path is defined on the remote, Python: Default Interpreter Path is defined on the remote, for the workspace and folder
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:
This would actually be incorrect because you have path such as: "/h/[username]/venvs/cv/bin/python3",
Ideally you should create virtual environment INSIDE and dedicated for your workspace. Give these a try if you haven't already - create environment command and select the interpreter with the interpreter selector.
Tried unsuccessfully:
2024-10-11 15:06:09.104 [info] Selected interpreter /h/denistr1/python/Python-3.12.0/python for creating virtual environment.
2024-10-11 15:06:28.292 [info] Running Env creation script: [
'/h/denistr1/python/Python-3.12.0/python',
'/h/denistr1/.vscode-server/extensions/ms-python.python-2024.16.0-linux-x64/python_files/create_venv.py',
'--git-ignore'
]
2024-10-11 15:06:28.292 [info] > ~/python/Python-3.12.0/python ~/.vscode-server/extensions/ms-python.python-2024.16.0-linux-x64/python_files/create_venv.py --git-ignore
2024-10-11 15:06:28.292 [info] cwd: .
2024-10-11 15:06:28.295 [info] /h/denistr1/python/Python-3.12.0/python: /lib64/libm.so.6: version GLIBC_2.29' not found (required by /h/denistr1/python/Python-3.12.0/python) /h/denistr1/python/Python-3.12.0/python: /lib64/noelision/libpthread.so.0: version
GLIBC_2.30' not found (required by /h/denistr1/python/Python-3.12.0/python)
/h/denistr1/python/Python-3.12.0/python: /lib64/libc.so.6: version GLIBC_2.28' not found (required by /h/denistr1/python/Python-3.12.0/python) /h/denistr1/python/Python-3.12.0/python: /lib64/libc.so.6: version
GLIBC_2.25' not found (required by /h/denistr1/python/Python-3.12.0/python)
/h/denistr1/python/Python-3.12.0/python: /lib64/libc.so.6: version GLIBC_2.26' not found (required by /h/denistr1/python/Python-3.12.0/python) /h/denistr1/python/Python-3.12.0/python: /lib64/libc.so.6: version
GLIBC_2.27' not found (required by /h/denistr1/python/Python-3.12.0/python)
2024-10-11 15:06:28.295 [error] Error while running venv creation script: undefined
2024-10-11 15:06:28.295 [error] Failed to create virtual environment with exitCode: 1
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:
This would actually be incorrect because you have path such as: "/h/[username]/venvs/cv/bin/python3",
What's incorrect @anthonykim1 ?
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. If it were to be non-global, it would not be under your such path and under venvs, but rather will be under your project workspace directory.
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 /python/Python-3.12.0/python
the very first Python folder where you store multiple Python versions?
It may be helpful for you to rename the very first Python word to something else usually "python" would be the executable itself.
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