
When you try to run the Jupyter Notebook application, you might get an error in the terminal as follows:
Error executing Jupyter command 'notebook': [Errno 2] No such file or directory
This error usually happens in Ubuntu systems. While the cause is uncertain, the error seems to come from the split between IPython and Project Jupyter earlier.
The following sections show possible causes for this error and how you can fix it.
1. Uninstall IPython
If you have IPython installed, then you might still have an old version of the notebook package that’s no longer available. You need to remove ipython from your computer.
Run the following commands from the terminal:
# Remove and clean IPython from the system
sudo apt-get remove ipython
sudo apt-get purge ipython
sudo apt-get autoremove
# Install jupyter with pip
pip install jupyter
# Or if you have pip3:
pip3 install jupyter
The jupyter package from PyPi will install all Jupyter components in one go.
Once jupyter is installed, run the command jupyter notebook to activate the Jupyter Notebook.
If that doesn’t work, try the python3 -m notebook command.
2. Using conda
If you’re using conda as the package manager on your computer, then you can try updating conda and reinstalling jupyter with the following commands:
conda update -n base conda
conda install jupyter --force-reinstall
Once finished, run the command jupyter notebook to run the Jupyter server.
You should see a new browser window opened showing the Notebook interface:
3. Force clean install
If you see this error and you installed the notebook using pip install "ipython[notebook]" command, try to reinstall notebook using the jupyter package:
# Python 2:
pip install --upgrade --force-reinstall --no-cache-dir jupyter
# Python 3:
pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
The commands above will install the latest jupyter package without using the version cached on your system.
Run the jupyter notebook command again to verify that the error has been resolved.
4. Installed jupyter-core using apt
If you installed the jupyter-core package using apt, then you can’t run the Notebook as jupyter-core only contain the core modules.
You can verify this by running the jupyter -H command. See there are only migrate and troubleshoot subcommands in the output below:
To get the notebook subcommand, you need to install the jupyter-notebook package with apt as follows:
sudo apt install jupyter-notebook
# If you see any error, add --fix-missing flag
sudo apt install jupyter-notebook --fix-missing
Once the installation is finished, you can run the command jupyter -H again and see that the notebook subcommand is available:
To get the Notebook up, simply run the jupyter notebook command from the terminal.
Maybe it’s my internet speed, but I found that installing Jupyter using pip is faster than apt.
You can install pip in Ubuntu and then use it to install the Jupyter Notebook with these commands:
# Install pip
sudo apt install python3-pip
# Then install the notebook
pip3 install jupyter
Once finished, you should be able to run Jupyter Notebook with python3 -m notebook command.
Conclusion
The error executing Jupyter command 'notebook': [Errno 2] No such file or directory frequently occurs when you have outdated Jupyter packages installed on your computer.
I hope the solutions provided in this article are helpful. Happy coding! 👍


