skip to Main Content

My vscode shows version 3.9.13 64bit of python:

enter image description here

However there are many versions of python installed on my machine (dont know how!)

enter image description here

When I run python shell in terminal, it picks up version 3.7.9

enter image description here

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:

enter image description here

Also it does not seem to detect any kernels installed:

enter image description here

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


  1. 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.

    $ ls -al /usr/bin/ | grep python
    lrwxrwxrwx 1 root   root           9 Mar 13  2020 python3 -> python3.8
    -rwxr-xr-x 1 root   root     5486352 Jul 28  2020 python3.8
    

    When you type python3 in your terminal, the one that you get is the first found when searching the system PATH. You can easily check printing PATH variable

    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    

    The 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

    Login or Signup to reply.
  2. Try to re-install jupyter’s extensions and restart vs code, it worked for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search