Last updated: Apr 10, 2024
Reading timeยท4 min

The "Error executing Jupyter command 'notebook': [Errno 2] No such file or directory" most commonly occurs on Linux distributions, e.g. Ubuntu or Arch.
The error occurs for multiple reasons:
jupyter notebook command.The jupyter notebook command sometimes clashes with the IPython module.
The first thing you should try is to uninstall IPython.
# ๐๏ธ Uninstall the IPython module sudo apt remove ipython sudo apt purge ipython sudo apt autoremove # ๐๏ธ Install the Jupyter module pip install jupyter # ๐๏ธ Or with pip3 pip install jupyter

Try to issue the jupyter notebook command after uninstalling IPython.
jupyter notebook
Make sure you have the python-dev package installed if you are on Linux.
# ๐๏ธ For Debian (Ubuntu) sudo apt install python3-pip python3-dev # ๐๏ธ For Redhat / CentOS sudo yum install python3-devel # ๐๏ธ For Alpine Linux sudo apk add python3-dev # ๐๏ธ For openSUSE sudo zypper in python3-devel # ๐๏ธ For Cygwin apt-cyg install python3-devel

Now, reinstall the jupyter module using the --force-reinstall option.
# for python 2 pip install --upgrade --force-reinstall --no-cache-dir jupyter # for python 3 pip3 install --upgrade --force-reinstall --no-cache-dir jupyter

You can read more about pip's --no-cache-dir option in the
following article.
If you get a permissions error when running the command, add the --user
option.
# For python 2 pip install --user --upgrade --force-reinstall --no-cache-dir jupyter # For python 3 pip3 install --user --upgrade --force-reinstall --no-cache-dir jupyter
If you still get a permissions error, try prefixing the command with sudo.
# For python 2 sudo pip install --upgrade --force-reinstall --no-cache-dir jupyter # For python 3 sudo pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
Try to issue the jupyter notebook command after uninstalling IPython.
jupyter notebook
After you issue the command, the server should start and you should see the Notebook app in your browser.

jupyter notebook commandThe jupyter notebook command sometimes changes to a different alias after
installation.
Try running the following command instead.
jupyter-notebook

Notice that the words are separated by a hyphen.
If the command doesn't start the server, try using the python -m notebook
command instead.
python -m notebook # Or python3 python3 -m notebook

If the python -m notebook command words, use the export command to update
your PATH environment variable.
export PATH=$PATH:~/.local/bin/

Make sure to restart your terminal after using the export command for the
changes to take effect.
After you've restarted your terminal, try issuing the jupyter notebook
command.
jupyter notebook
apt packaging toolIf the error persists, try installing jupyter using apt.
# Update packages sudo apt update # Install pip and Python sudo apt install python3-pip python3-dev # Upgrade pip sudo -H pip3 install --upgrade pip # Install jupyter-notebook sudo apt install jupyter-notebook

After running the sudo apt install jupyter-notebook, try issuing the
jupyter notebook command.
jupyter notebook
If the error persists, get your Python version and make sure you are installing the package using the correct Python version.
python --version

For example, my Python version is 3.11.2, so I would
install the GitPython package with
pip3.10 install jupyter.
pip3.11 install --upgrade --force-reinstall --no-cache-dir jupyter

Notice that the version number corresponds to the version of pip I'm using.
If you get a permissions error when running the command, add the --user
option.
pip3.11 install --user --upgrade --force-reinstall --no-cache-dir jupyter
If you still get a permissions error, try prefixing the command with sudo.
sudo pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
Try to issue the jupyter notebook command after installing the module with a
specific pip version.
jupyter notebook
If the error persists, try using one of the aliases of the jupyter notebook
command.
jupyter-notebook

Notice that the words are separated by a hyphen.
If the command doesn't start the server, try using the python -m notebook
command instead.
python -m notebook # or python3 python3 -m notebook

If the python -m notebook command words, use the export command to update
your PATH environment variable.
export PATH=$PATH:~/.local/bin/

Make sure to restart your terminal after using the export command for the
changes to take effect.
After you've restarted your terminal, try issuing the jupyter notebook
command.
jupyter notebook
To solve the "error executing Jupyter command 'notebook': [Errno 2] No such file
or directory", reinstall your jupyter module using pip or apt and make
sure the IPython module is not installed as it often clashes with jupyter.
You can learn more about the related topics by checking out the following tutorials: