microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.32k stars 1.18k forks source link

python version wrongly detected in conda envs #23723

Closed matilde-t closed 3 months ago

matilde-t commented 3 months ago

Type: Bug

Behaviour

When choosing a python environment, all conda environments show as 3.1.x even if the python version is higher. In fact, even in the logs below it shows Python version (& distribution if applicable, e.g. Anaconda): 3.1, but it's false.

image

As you can see, the base version is correctly detected, but it's not the case for the other envs.

Steps to reproduce:

  1. Create conda env
  2. Select it with "select interpreter"

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` 2024-06-29 17:23:54.882 [info] Telemetry level is off 2024-06-29 17:23:54.882 [info] Experiments are disabled, only manually opted experiments are active. 2024-06-29 17:23:54.882 [info] Default formatter is set to null for workspace /home/mati/Desktop/TUM/4.Algorithms_for_UQ/Tutorial8 2024-06-29 17:23:55.002 [info] > pyenv which python 2024-06-29 17:23:55.002 [info] cwd: . 2024-06-29 17:23:55.014 [info] > conda info --json 2024-06-29 17:23:56.352 [info] > ~/miniconda3/envs/UQ/bin/python -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:23:56.435 [info] Python interpreter path: ~/miniconda3/envs/UQ/bin/python 2024-06-29 17:23:58.636 [info] Starting Pylance language server. 2024-06-29 17:24:02.022 [info] Telemetry level is off 2024-06-29 17:24:02.022 [info] Experiments are disabled, only manually opted experiments are active. 2024-06-29 17:24:02.022 [info] Default formatter is set to null for workspace /home/mati/Desktop/TUM/4.Algorithms_for_UQ/Tutorial9 2024-06-29 17:24:02.022 [info] Starting Environment refresh 2024-06-29 17:24:02.022 [info] Starting Environment refresh 2024-06-29 17:24:02.033 [info] > hatch env show --json 2024-06-29 17:24:02.033 [info] cwd: . 2024-06-29 17:24:02.041 [info] Python interpreter path: ~/miniconda3/bin/python 2024-06-29 17:24:02.082 [info] > conda info --json 2024-06-29 17:24:04.158 [info] Environments refresh finished (event): 2149 milliseconds 2024-06-29 17:24:04.159 [info] Environments refresh paths discovered: 2150 milliseconds 2024-06-29 17:24:04.160 [info] Environments refresh finished (event): 2171 milliseconds 2024-06-29 17:24:04.160 [info] Environments refresh paths discovered: 2171 milliseconds 2024-06-29 17:24:04.163 [info] Environment refresh took 2154 milliseconds 2024-06-29 17:24:04.167 [info] Environment refresh took 2179 milliseconds 2024-06-29 17:24:04.173 [info] > pyenv which python 2024-06-29 17:24:04.173 [info] cwd: . 2024-06-29 17:24:06.709 [info] Starting Pylance language server. 2024-06-29 17:25:09.331 [info] Starting Environment refresh 2024-06-29 17:25:09.331 [info] Searching for interpreters in posix paths locator 2024-06-29 17:25:09.332 [info] Searching for pyenv environments 2024-06-29 17:25:09.333 [info] Searching for conda environments 2024-06-29 17:25:09.333 [info] Searching for global virtual environments 2024-06-29 17:25:09.333 [info] Searching for custom virtual environments 2024-06-29 17:25:09.340 [info] > conda info --json 2024-06-29 17:25:09.342 [info] pyenv is not installed 2024-06-29 17:25:09.342 [info] Finished searching for pyenv environments: 11 milliseconds 2024-06-29 17:25:09.343 [info] Finished searching for custom virtual envs: 11 milliseconds 2024-06-29 17:25:09.344 [info] Finished searching for global virtual envs: 12 milliseconds 2024-06-29 17:25:09.378 [info] Found: /bin/python --> /bin/python3.10 2024-06-29 17:25:09.383 [info] Found: /bin/python2 --> /bin/python2.7 2024-06-29 17:25:09.384 [info] Found: /bin/python2.7 --> /bin/python2.7 2024-06-29 17:25:09.384 [info] Found: /bin/python3 --> /bin/python3.10 2024-06-29 17:25:09.384 [info] Found: /bin/python3.10 --> /bin/python3.10 2024-06-29 17:25:09.384 [info] Found: /bin/python3.8 --> /bin/python3.8 2024-06-29 17:25:09.434 [info] Found: /usr/bin/python --> /usr/bin/python3.10 2024-06-29 17:25:09.434 [info] Found: /usr/bin/python2 --> /usr/bin/python2.7 2024-06-29 17:25:09.434 [info] Found: /usr/bin/python2.7 --> /usr/bin/python2.7 2024-06-29 17:25:09.434 [info] Found: /usr/bin/python3 --> /usr/bin/python3.10 2024-06-29 17:25:09.434 [info] Found: /usr/bin/python3.10 --> /usr/bin/python3.10 2024-06-29 17:25:09.435 [info] Found: /usr/bin/python3.8 --> /usr/bin/python3.8 2024-06-29 17:25:10.214 [info] > /bin/python -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.242 [info] > /bin/python2 -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.248 [warning] [Error: Command failed: /bin/python2 -I /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py Unknown option: -I usage: /bin/python2 [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information. at ChildProcess.exithandler (node:child_process:423:12) at ChildProcess.emit (node:events:526:35) at maybeClose (node:internal/child_process:1105:16) at Socket. (node:internal/child_process:457:11) at Socket.emit (node:events:514:28) at Pipe. (node:net:337:12)] { code: 2, killed: false, signal: null, cmd: '/bin/python2 -I /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py' } 2024-06-29 17:25:10.249 [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-06-29 17:25:10.255 [info] > /bin/python2 ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.272 [info] Finished searching for conda environments: 940 milliseconds 2024-06-29 17:25:10.296 [info] > /bin/python3.8 -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.316 [info] > /usr/bin/python -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.332 [info] Finished searching for interpreters in posix paths locator: 1003 milliseconds 2024-06-29 17:25:10.351 [info] Environments refresh paths discovered (event): 1023 milliseconds 2024-06-29 17:25:10.352 [info] Environments refresh paths discovered: 1023 milliseconds 2024-06-29 17:25:10.362 [info] > /usr/bin/python2 -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.373 [info] > /usr/bin/python3.8 -I ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.374 [warning] [Error: Command failed: /usr/bin/python2 -I /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py Unknown option: -I usage: /usr/bin/python2 [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information. at ChildProcess.exithandler (node:child_process:423:12) at ChildProcess.emit (node:events:526:35) at maybeClose (node:internal/child_process:1105:16) at Socket. (node:internal/child_process:457:11) at Socket.emit (node:events:514:28) at Pipe. (node:net:337:12)] { code: 2, killed: false, signal: null, cmd: '/usr/bin/python2 -I /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py /home/mati/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py' } 2024-06-29 17:25:10.374 [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-06-29 17:25:10.381 [info] > /usr/bin/python2 ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.8.1/python_files/interpreterInfo.py 2024-06-29 17:25:10.417 [info] Environments refresh finished (event): 1089 milliseconds 2024-06-29 17:25:10.449 [info] Environment refresh took 1121 milliseconds 2024-06-29 17:25:11.843 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:25:11.843 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:25:11.845 [info] Discover tests for workspace name: Tutorial9 - uri: /home/mati/Desktop/TUM/4.Algorithms_for_UQ/Tutorial9 2024-06-29 17:25:11.846 [info] Python interpreter path: ~/miniconda3/envs/UQ/bin/python 2024-06-29 17:25:11.847 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:25:11.853 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:25:11.855 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:32:33.162 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:32:33.313 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:32:33.369 [error] Invalid version for /home/mati/miniconda3/envs/UQ/bin/python: {"name":"UQ","location":"/home/mati/miniconda3/envs/UQ","kind":"virt-conda","executable":{"filename":"/home/mati/miniconda3/envs/UQ/bin/python","sysPrefix":"/home/mati/miniconda3/envs/UQ","ctime":1715181098263,"mtime":1715181098263},"display":"Python 3.1.x ('UQ')","version":{"major":3,"minor":1,"micro":-1},"arch":1,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/home/mati/miniconda3/envs/UQ/bin/python","detailedDisplayName":"Python 3.1.x ('UQ': conda)"} 2024-06-29 17:32:33.762 [info] > conda info --json 2024-06-29 17:32:34.808 [info] Send text to terminal: conda activate UQ 2024-06-29 17:32:34.931 [info] Send text to terminal: /usr/bin/env /home/mati/miniconda3/envs/UQ/bin/python /home/mati/.vscode/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 60311 -- /home/mati/Desktop/TUM/4.Algorithms_for_UQ/Tutorial9/ex2_template.py ```

Extension version: 2024.8.1 VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:33:48.698Z) OS version: Linux x64 6.9.3-76060903-generic Modes:

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |Black Formatter|ms-python.black-formatter|2024.2.0| |C/C++|ms-vscode.cpptools|1.20.5| |C/C++ Extension Pack|ms-vscode.cpptools-extension-pack|1.3.0| |C/C++ Themes|ms-vscode.cpptools-themes|2.0.0| |Clang-Format|xaver.clang-format|1.9.0| |Dev Containers|ms-vscode-remote.remote-containers|0.369.0| |Docker|ms-azuretools.vscode-docker|1.29.1| |GitHub Markdown Preview|bierner.github-markdown-preview|0.3.0| |godot-tools|geequlim.godot-tools|2.0.0| |HTML Preview|george-alisson.html-preview-vscode|0.2.5| |JavaScript Debugger|ms-vscode.js-debug|1.90.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Jupyter|ms-toolsai.jupyter|2024.5.0| |Jupyter Cell Tags|ms-toolsai.vscode-jupyter-cell-tags|0.1.9| |Jupyter Keymap|ms-toolsai.jupyter-keymap|1.1.2| |Jupyter Notebook Renderers|ms-toolsai.jupyter-renderers|1.0.18| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |LaTeX Workshop|James-Yu.latex-workshop|10.1.0| |Makefile Tools|ms-vscode.makefile-tools|0.9.10| |Markdown Preview Github Styling|bierner.markdown-preview-github-styles|2.0.4| |markdownlint|DavidAnson.vscode-markdownlint|0.55.0| |Material Theme|Equinusocio.vsc-material-theme|34.4.0| |Mono Debug|ms-vscode.mono-debug|0.16.3| |PDF Viewer|mathematic.vscode-pdf|0.0.6| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.8.1| |Python Debugger|ms-python.debugpy|2024.6.0| |Remote - SSH|ms-vscode-remote.remote-ssh|0.112.0| |Remote - SSH: Editing Configuration Files|ms-vscode-remote.remote-ssh-edit|0.86.0| |Remote Development|ms-vscode-remote.vscode-remote-extensionpack|0.25.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9| |tango-plus|ludwigkr.emacs-tango-plus|0.1.0|
System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2799)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 1, 1| |Memory (System)|15.54GB (7.73GB free)| |Process Argv|| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|pop-wayland| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|pop-wayland| |XDG_SESSION_TYPE|wayland|
karthiknadig commented 3 months ago

Duplicate of https://github.com/microsoft/vscode-python/issues/23649

This is fixed in pre-release please try it.