Description
Type: Bug
Behaviour
After an OS upgrade replaced an old Python with a new version, VS Code fails to detect the new version.
Steps to reproduce
I use Linux Mint. Version 21 included Python 3.10.12 with symlinks in /bin/python3
and /usr/bin/python3
. VS code detected these and things worked just fine.
I recently upgraded to Mint version 22, which removed the Python 3.10.12 and replace it with Python 3.12.3. In a shell:
> which python3
/usr/bin/python3
> python3 --version
Python 3.12.3
However, if I use Python: Select Interpreter
I get the following:
Notice that VS Code still believes that the system Python is 3.10.12. Just to be clear: I have restarted VS Code multiple times since the OS upgrade.
I reviewed the documentation. This document says that Python will detect the Python versions automatically. Clearly, it did not.
Python 3.10.12 no longer exists on the system. Yet, the Python extension seems to believe that the Python in /bin/python3
is that version. Perhaps the version information is cached. However, the documentation provides no hints (which I could find) to tell VS Code to flush its cache and to go out and look to see which version is actually installed.
At the same time, Jupyter fails to detect this version also. Create a new notebook. Select "Select Interpreter." Only the non-existent 3.10.12 interpreter is listed. Now, it could be that Jupyter fails to find the system Python because that version is managed by the OS and I've not installed the required Python modules, though the documentation says that I'll be prompted to install them.
My workaround was to create a virtual environment (in a terminal). In a terminal, with the virtual environment added to the path:
> which python
/home/paul/pyenv/3.12/bin/python
> python --version
Python 3.12.3
The documentation says that this virtual environment will be detected automatically, since it is in ~/pyenv
. However, it was not. I was able to configure it via Python: Select Interpreter/Enter Interpreter Path
.
Then, I had to install IPyKernel
by hand after which I could finally select the correct interpreter in a new Juypter notebook.
Specific Issues
- Neither the Python nor Jupyter extensions have noticed that Python was upgraded.
- It may be that the displayed version number is just cosmetic and does not affect operation. Still, it would be good for it to be correct.
- The Python extension did not find my virtual environment as promised: I had to configure it manually.
- The Jupyter extension did not find my virtual environment and install the
IPyKernel
module as promised in the documentation. - Either provide information on how to diagnose such problems (perhaps turn on logging somewhere), or if there is no current mechanism, please provide one that tells me exactly where the Python and Jupyter extensions are searching, why, and why they choose to not find my interpreters.
Diagnostic data
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
XXX
Extension version: 2024.16.1
VS Code version: Code 1.95.0 (912bb683695358a54ae0c670461738984cbb5b95, 2024-10-28T20:16:24.561Z)
OS version: Linux x64 6.8.0-47-generic
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.12.3
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServer
setting: Pylance
User Settings
languageServer: "Pylance"
testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true
Installed Extensions
Extension Name | Extension Id | Version |
---|---|---|
Code Spell Checker | streetsidesoftware.code-spell-checker | 3.0.1 |
Debugger for Java | vscjava.vscode-java-debug | 0.58.0 |
Extension Pack for Java | vscjava.vscode-java-pack | 0.29.0 |
GitLens — Git supercharged | eamodio.gitlens | 15.6.2 |
Gradle for Java | vscjava.vscode-gradle | 3.16.4 |
IntelliCode | VisualStudioExptTeam.vscodeintellicode | 1.3.2 |
IntelliCode API Usage Examples | VisualStudioExptTeam.intellicode-api-usage-examples | 0.2.9 |
JavaScript Debugger | ms-vscode.js-debug | 1.95.1 |
JavaScript Debugger Companion Extension | ms-vscode.js-debug-companion | 1.1.3 |
Jupyter | ms-toolsai.jupyter | 2024.10.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.20 |
Language Support for Java(TM) by Red Hat | redhat.java | 1.35.1 |
markdownlint | DavidAnson.vscode-markdownlint | 0.56.0 |
Maven for Java | vscjava.vscode-maven | 0.44.0 |
Project Manager for Java | vscjava.vscode-java-dependency | 0.24.0 |
Pylance | ms-python.vscode-pylance | 2024.10.1 |
Python | ms-python.python | 2024.16.1 |
Python Debugger | ms-python.debugpy | 2024.12.0 |
Rainbow CSV | mechatroner.rainbow-csv | 3.12.0 |
Rewrap | stkb.rewrap | 1.16.3 |
Scientific Terms - Code Spell Checker | streetsidesoftware.code-spell-checker-scientific-terms | 0.2.2 |
Table Visualizer for JavaScript Profiles | ms-vscode.vscode-js-profile-table | 1.0.10 |
Test Runner for Java | vscjava.vscode-java-test | 0.42.0 |
System Info
Item | Value |
---|---|
CPUs | Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (8 x 4429) |
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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 webnn: disabled_off |
Load (avg) | 3, 2, 2 |
Memory (System) | 31.31GB (10.72GB free) |
Process Argv | --crash-reporter-id 5e232e7b-355a-468c-ac4a-02c300f898bd |
Screen Reader | no |
VM | 0% |
DESKTOP_SESSION | cinnamon |
XDG_CURRENT_DESKTOP | X-Cinnamon |
XDG_SESSION_DESKTOP | cinnamon |
XDG_SESSION_TYPE | x11 |
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
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
g316j359:31013175
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
wkspc-onlycs-t:31132770
nativeloc1:31134641
wkspc-ranged-t:31151552
cf971741:31144450
iacca1:31156133
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013