Report this

What is the reason for this report?

Jupyter Notebook Python version kernel

Posted on January 12, 2021

How to change the kernel of my Jupyter Notebook from using Python3.8.7 to Python3.9.1? Jupyter Notebook run outside Anaconda on MacOS BigSur 11.1, Jupyter Notebook was though pip. Python version just recently upgraded to 3.9.1. Thank you.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You can verify what kernels are available to Jupyter by running:

jupyter kernelspec list

If you’ve installed 3.9.1 and its in the search pathway for Jupyter, it should be listed there. You can then choose the kernel at runtime in the top right corner of the notebook. If it doesn’t show up, that’s a longer answer and I would start by reading through this thread.

To change the kernel of your Jupyter Notebook from Python 3.8.7 to Python 3.9.1 on macOS Big Sur, you’ll first need to ensure that Python 3.9.1 is installed and then create a new Jupyter kernel that uses this version of Python. Here’s a detailed guide on how to do it:

Step 1: Install Python 3.9.1

It sounds like you’ve already upgraded to Python 3.9.1, but just to confirm, you can check the Python version by running:

python3 --version

If it’s not installed, you can install Python 3.9.1 using Homebrew (if you use Homebrew):

brew install python@3.9

And make sure it’s in your PATH:

echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Step 2: Set Up Python 3.9.1 with pip

Make sure that pip is updated for the Python 3.9 installation:

python3.9 -m pip install --upgrade pip

Step 3: Install Jupyter Notebook

If not already installed under Python 3.9.1, install Jupyter:

python3.9 -m pip install jupyter

Then, add a new kernel:

python3.9 -m ipykernel install --user --name python391 --display-name "Python 3.9.1"

This command creates a new kernel named “Python 3.9.1” that points to your Python 3.9.1 installation.

Step 5: Start Jupyter Notebook

Run Jupyter Notebook:

jupyter notebook

Step 6: Select the New Kernel in Jupyter Notebook

Once your notebook is open:

  1. Go to the “Kernel” menu.
  2. Click on “Change kernel”.
  3. Select “Python 3.9.1” from the list.

Now, your notebook should be running with Python 3.9.1. You can check the Python version in a notebook cell by running:

import sys
print(sys.version)

This should output something like 3.9.1, confirming that the notebook is using the correct version of Python.

Troubleshooting

If you encounter issues where the kernel does not appear or Jupyter complains about not finding the kernel, double-check the paths and environment settings. Restarting the terminal, or sometimes the whole system, can help refresh environment settings if something seems off.

This approach ensures that your Jupyter Notebook environment is updated and capable of utilizing the features offered by Python 3.9.1.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.