-
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
Python & Jupyter extension fail to detect upgraded Python #24364
Comments
We typically don't re-run detection is some of these cases. A workaround is to run |
@karthiknadig, thanks for the explanation. I ran that command and it did, indeed "forget about" the old Python versions and found the updated version. Unfortunately, if also forgot about my virtual environment and did not find it when I selected It would be helpful to add to the documentation the steps needed when the system Python is upgraded:
Step 3 above is needed in systems like Linux Mint (Ubuntu base) where the system interpreter is "managed" and does not easily allow installing user-specific packages. |
You should be able to see in the logs for Output > Python and Output > Python Locator to see what it is looking for. |
@karthiknadig, thanks for the suggestion. It seems that the internals found the virtual environment, but not the I ran another
The whole process seems to have been repeated a couple more times though I triggered a refresh only once. The above suggests that the code did find my environment. In fact, the code did so a total of about 50 times. (Why so many?) However, if I then do Notice that the virtual environment does not appear on the list though it is marked as the selected interpreter. The expected behavior is that, if the code did discover my virtual environment, that it would be available as one of the interpreters so I can select it. Any reason that it does not appear in the UI interpreter list? A subtle point is that the first time I did the above, my virtual environment was not selected. The second time, the virtual environment selection appeared to "survive" the All of this would just be an annoying UI glitch if it were not then for Jupyter. Using Now, to be complete, let's select another interpreter using Let's try one more trick. Again run Finally, I used Fortunately, after I manually configure the virtual environment, it does then show up in the above Jupyter In fact, once I configure my environment manually, the notebook then automatically selects that kernel, likely because the kernel name is stored in the notebook itself. Thus, the Bottom line: this is all rather fiddly and could, perhaps, be streamlined a bit to avoid the need to ask for help for such a simple task. To be clear, the following would be helpful:
|
@paul-rogers Can you check what the locator has two options |
@karthiknadig, the |
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:
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:
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 viaPython: 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
IPyKernel
module as promised in the documentation.Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)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.languageServer
setting: PylanceUser Settings
Installed Extensions
System Info
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
A/B Experiments
The text was updated successfully, but these errors were encountered: