skip to Main Content

I’ve done a fair amount of code for statistics (mainly R), but I’m quite new to Python and modules etc.

I work with an Ubuntu 22.04, and I installed vscode and the latest version of Python (pyhton3.12). However, as the version python3.10 is used by the OS, I left it this one as my default version.

If I do:

$ python3 --version
Python 3.10.12

And to use the version 3.12, I have to explicitly say so.

The problem comes when I try to use a jupyter notebook in VS code.
I tried to run with the kernel 3.12, and it told me that I needed to perform the installation of the Ipykernel.

/bin/python3.12 -m pip install ipykernel -U --user –force-reinstall

However, I was not able to install this kernel, as I was missing the ‘disutils’ package, which I had a lot of problems installing as well. So what I decided to do, is check if I could install the kernel in the 3.10 version, as it’s the default used by the OS, and it worked (I guess the default version has the ‘disutils’ package correctly installed)

I’d like to use the kernel of 3.12, however, I don’t know how to install it.
Is there a way of leaving the 3.10 version as default for the OS, but using the 3.12 everywhere else, or could this create conflict?

2

Answers


  1. Not in vscode.

    For .py files you can Ctrl+Shift+P –> Python: Select Interpreter to choose a specific version of interpreter for it.

    https://code.visualstudio.com/docs/python/environments#_working-with-python-interpreters

    For jupyter, just click on the kernel version in the top right corner to switch.

    enter image description here

    Login or Signup to reply.
  2. I also just had this problem. I hope it helps you.

    The next thing you should do in the terminal is:

    sudo apt-get install python3.12-distutils
    
    python3.12 -m pip install ipykernel
    
    curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
    

    I took these steps from:
    Running cells with Python 3.10 requires ipykernel installed

    Only I changed the commands to the current version.

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