How to fix “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory”

Jupyter notebook is a web application that is used for a wide variety of functions such as coding, managing data, or databases. The problem “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory” occurs while trying to run the Jupyter notebook after completing its installation. In the following post, you will learn to fix the error and successfully run Jupyter notebook on your system.

Reason: Faulty Installation

On some systems, when Jupyter is installed and then started using the “Jupyter notebook” command, the message “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory” is invoked. If your Jupyter notebook has not been installed correctly on your system it is very likely that you will encounter this issue while trying to run it.

Solution: Reinstall Jupyter Notebook

Perhaps the simplest way to get Jupyter Notebook to launch is to reinstall the software. Below are some of the ways in which you can reinstall Jupyter on Linux.

Step 1: Uninstall Jupyter Notebook

Firstly, we need to remove the broken version of Jupyter notebook from your system. To do so, the following command is executed:

$ sudo apt remove Jupyter-notebook

The following message will appear once Jupyter Notebook is successfully removed from your system:

Once Jupyter Notebook has been removed from your system, you can proceed with installing it again.

The following steps lead to a fresh installation of Python:

Step 2: Update the System

It needs to be assured that all your packages are updated. Run these two statements to update:

$ sudo apt update
$ sudo apt upgrade

Step 3: Install Python and Upgrade Pip

The most important step in this process is to install Python and then upgrade your pip which is an installer designed specifically for packages related to Python. It will assist us in installing the Jupyter Notebook. Use these commands if pip is not installed:

$ sudo apt install python3-pip python3-dev
$ sudo -H pip3 install --upgrade pip

The first command will install the pip tool from python3 and the next command will upgrade it to the latest version if any is available.

Step 4: Installation and Creation of a Virtual Environment

Once upgraded, we can install Python’s virtual environment using the statement below:

$ sudo -H pip3 install virtualenv

Now create the environment and activate it by following these commands:

$ mkdir notebook
$ cd notebook
$ virtualenv Jupyterenv

The virtual environment has been created now.

Step 5: Activate the Environment

Activate the virtual environment by issuing the below-stated command:

$ source Jupyterenv/bin/activate

Step 6: Install Jupyter Notebook

After the completion of the steps demonstrated above, your system is ready to install the Jupyter Notebook. Run this simple command to achieve that:

$ pip install Jupyter

Jupyter Notebook should now be installed on your system successfully.

Once you have installed Jupyter Notebook, you can check again and see that it is working.

Run this command below to see that there is no more “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory” problem occurring:

$ Jupyter notebook

Conclusion

The error titled “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory” occurs due to the faulty installed version of the Jupyter Notebook at the user end. This error can be fixed by removing the earlier versions and re-installing the Jupyter Notebook. In this post, we have demonstrated the reason that invokes “Error executing Jupyter command ‘notebook’: [Errno 2] No such file or directory” and the solution to counter this reason is also provided.