How do I get Jupyter Notebook to use the latest version of Python installed on my PC?

Viewed 4452

I have python 3.10 installed on my PC but every time I open a new Jupyter Notebook and check the version it still says that I am using the previous version that I had. Is there a way to make it start using the latest version every time I open a new notebook? Thanks

1 Answers

You should try to work with virtual environments. They are very commonly used in Python. Then, on your Jupyter Notebook, you will be able to choose the particular environment (and Python version) you want to run your notebook.

First, create a virtual environment using Python 3.10:

pip install virtualenv
virtualenv nameofthevenv --python python3.10
source nameofthevenv/bin/activate

Then, inside the virtualenv:

(nameofthevenv) $ pip install jupyter ipykernel
(nameofthevenv) $ python -m ipykernel install --user --name nameofthevenv
(nameofthevenv) $ jupyter notebook

Finally, go to the page in your browser the last command opened, and choose the running kernel at the top right: Kernel >> Change Kernel >> <list of kernels>. You will see nameofthevenv. Select it and you're good to go: the python version will be Python 3.10.

Related