microsoft / vscode-python

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

2024.8.0 cannot recognize the Python version in conda base env #23580

Closed scaomath closed 3 months ago

scaomath commented 3 months ago

Type: Bug

Behaviour

2024.8.0 recognizes Python 3.11.9 as 3.1.x, and gives the warning message that this version is not supported. However, both local and conda venv using 3.11.9 are correctly recognized.

Downgrading to 2024.6.0 solves the problem.

Steps to reproduce:

  1. Create a new profile that is free of all extension.
  2. Either use command palette or look at the bottom right corner of the Python version (if the original workspace setting is using the base conda, and the Python version is 3.11.9), the version becomes 3.1.x.
  3. Downgrading to 2024.6.0 this problem is gone.

Diagnostic data

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

``` XXX ```

Extension version: 2024.8.0 VS Code version: Code 1.90.0 (89de5a8d4d6205e5b11647eb6a74844ca23d2573, 2024-06-04T19:43:07.605Z) OS version: Linux x64 5.15.0-107-generic Modes:

User Settings

``` Multiroot scenario, following user settings may not apply: languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |JavaScript Debugger|ms-vscode.js-debug|1.90.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.6.0| |Python Debugger|ms-python.debugpy|2024.6.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|
System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz (20 x 4799)| |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, 2, 1| |Memory (System)|125.60GB (116.21GB free)| |Process Argv|--crash-reporter-id ac909399-c666-4e3c-a14b-b72345a6de8f| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 chatpanelt:31048053 dsvsc021:30996838 jg8ic977:31013176 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 pythonprt:31056678 dwnewjupytercf:31046870 fa862199:31048878 ```
scaomath commented 3 months ago

Screenshot from 2024-06-08 08-05-27

Screenshot from 2024-06-08 08-06-02

kennethso168 commented 3 months ago

I can reproduce this with conda and python 3.12. For me, the base env and most other envs are unaffected and shows the correct python version. After repeated testing I found that the issue would occur if the conda package python-tzdata was installed in that env.

To reproduce:

Create a new conda environment with python 3.12 and python-tzdata

mamba create --name test python=3.12 python-tzdata

You can see that the 'test' environment shows version 3.1.x

Screenshot_20240608_235745

Destroy and recreate the environment with python 3.12 only

conda remove -n test --all
mamba create --name test python=3.12

Now the 'test' environment shows version 3.12.3 correctly

Screenshot_20240608_235906

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |Ansible|redhat.ansible|24.5.2| |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| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.8.0| |Python Debugger|ms-python.debugpy|2024.6.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9| |YAML|redhat.vscode-yaml|1.15.0|
System Info ``` CPUs AMD Ryzen 5 PRO 4650G with Radeon Graphics (12 x 4167) 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) 0, 0, 0 Memory (System) 30.73GB (24.72GB free) Process Argv --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime --crash-reporter-id 7db031d7-2b48-4c62-bf40-22e7ce724e44 Screen Reader no VM 0% ```
A/B experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 showvideot:31016892 chatpanelc:31048052 dsvsc021:30996838 g316j359:31013175 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 pythonprt:31056678 dwnewjupyter:31046869 newcmakeconfigv2:31067619 fa862199:31048878 ```
VS Code Version details Version: 1.90.0 Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 Date: 2024-06-04T19:43:07.605Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.8.11-301.fsync.fc40.x86_64

Other information: This is using Miniforge on Bazzite (which is based on Fedora Atomic Desktop. VS Code is installed inside an Ubuntu 22.04 distrobox.

scaomath commented 3 months ago

If tzdata is the culprit as @kennethso168 suggested, then there is no way to get around it, as creating a new venv would install tzdata.

jinuhwang commented 3 months ago

I encountered the same issue where VS Code detects Python 3.11.9 as Python 3.1.xxx. found a temporary workaround by running "Reload Window" on the command palette.

TheWCKD commented 3 months ago

I can confirm the same issue lately with VS Code. Reloading the window seems to temporary fix it as @jinuhwang stated above.

zatkins2 commented 3 months ago

I have the same issue

basnijholt commented 3 months ago

I believe this issue is related to the python3.1 symlink as generated by conda (micromamba in my case): https://github.com/mamba-org/mamba/issues/3317.

torext commented 3 months ago

Similar issue here, though for me the base env (running Python 3.10.12) shows fine, but a newly created env running Python 3.11.9 intermittently shows as 3.1.x. FWIW, I do have the 3.1 symlink in there (though same is true in the base env bin folder), as well as python-tzdata 2024.1 installed in the new environment (but indeed not in the base one). Those two points were mentioned as being related to the issue at hand; seems python-tzdata might be more explanatory in my case just like for https://github.com/microsoft/vscode-python/issues/23580#issuecomment-2156092809.

scaomath commented 3 months ago

Another thing to add is that there is no such bug if one uses the old school pip .venv, even with tzdata installed.

torext commented 3 months ago

Another thing to add is that there is no such bug if one uses the old school pip .venv, even with tzdata installed.

Note that tzdata and python-tzdata are different packages; the latter is the one for which an issue arises.

maurerle commented 2 months ago

I still have this issue with vscode-python 2024.8.1, vscode 1.91

image

This is the case for python 3.11 and python 3.10 conda environments.

Version: 1.91.0
Commit: ea1445cc7016315d0f5728f8e8b12a45dc0a7286
Datum: 2024-07-01T18:52:41.959Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
Betriebssystem: Linux x64 6.8.0-36-generic snap

Update: installing the pre-release version fixes this issue. I now have vscode-python v24.11.2024070502 installed, which works fine.