My vscode shows version 3.9.13 64bit
of python:
However there are many versions of python installed on my machine (dont know how!)
When I run python shell in terminal, it picks up version 3.7.9
When I open jupyter notebook, and run any cell it says
Also when I run a cell in the jupyter notebook, it detects no python installed:
Also it does not seem to detect any kernels installed:
What is happening here?!! Is my Ubuntu installation screwed up?
I want same python (preferably 3.9, but 3.7 will also be ok) at all places: vscode bottom bar, terminal and also jupyter notebook. Also pip
should correspond to the same python. That is installing package through pip install
from terminal should make the package available to both python file and jupyter notebook. This is how it works on my Windows machine.
2
Answers
You have several Python(s) installed in your system. The typical installation path would be in
/usr/bin/python3
.Commonly,
/usr/bin/python3
it’s a symbolic link pointing toward the Python version installed in your system.When you type
python3
in your terminal, the one that you get is the first found when searching the systemPATH
. You can easily check printingPATH
variableThe same reasoning is valid for
pip
. I suggest you remove Python versions that you don’t use.Regarding VS Code, you can select the Python environment used using the bar at the bottom. To check whether VS Code is really using that environment, you can try to "right-click" a Python file and then
Run Python file in a terminal
.That command should output what is happening in the terminal tab.
If you are scared about removing other Python versions, you may create a separated Python environment. Here you can find some info about Python environments and use to use them with VS Code
Try to re-install jupyter’s extensions and restart vs code, it worked for me.