Last updated: Apr 10, 2024
Reading timeยท3 min
To resolve the Jupyter issue "Note: you may need to restart the kernel to use updated packages":
pip install
command with the --upgrade
option.The first thing you should try is to restart the kernel.
To restart the kernel:
CTRL + Enter
or
clicking on the > Run button.If the message is still shown when installing packages, try to refresh the page in your browser by pressing F5.
If the message is still shown, try to issue the pip install
command with the
--upgrade
option.
!pip install numpy --upgrade
Make sure to replace numpy
with the name of the package you're trying to
install.
If the message is still shown, try to create a new virtual environment.
To create a new virtual environment:
# ๐๏ธ Use the correct version of Python when creating VENV python -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1
If the python -m venv venv
command doesn't work, try the following 2 commands:
py -m venv venv
python3 -m venv venv
Make sure to use the correct command to activate your virtual environment depending on your operating system and your shell.
pip install ipykernel ipython kernel install --user --name=venv
jupyter notebook
command from your
terminal.jupyter notebook
Select venv
from the Change kernel menu and install all your packages.
Make sure the venv
kernel is selected and shown in the top right corner.
If you still get the message when running pip install <package>
, try to
upgrade pip
by running the following command from your terminal.
# ๐๏ธ On Linux or macOS python -m ensurepip --upgrade # ๐๏ธ Using python 3 python3 -m ensurepip --upgrade # ๐๏ธ On Windows py -m ensurepip --upgrade
ensurepip
package enables us to bootstrap the pip
installer into an existing Python installation or virtual environment.Alternatively, you can use the official get-pip script to install pip.
Download the script from https://bootstrap.pypa.io/get-pip.py by:
get-pip.py
file is downloaded and run the following command.# ๐๏ธ On Linux or macOS python get-pip.py # ๐๏ธ Using python 3 python3 get-pip.py # ๐๏ธ On Windows py get-pip.py
The get-pip.py
script uses bootstrapping logic to install pip
.
curl
(if you have curl
installed).curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # ๐๏ธ On Linux or macOS python get-pip.py --force-reinstall # ๐๏ธ Using python 3 python3 get-pip.py --force-reinstall # ๐๏ธ On Windows py get-pip.py --force-reinstall
The --force-reinstall option
forces pip
to reinstall the package.
If you still get the error, click on Kernel in the top menu and click Shutdown.
Then refresh the page, click on Kernel in the top bar and hover over the Change kernel menu.
Select venv
from the Change kernel menu and install all your packages.
You can learn more about the related topics by checking out the following tutorials: