How to Fix 'jupyter: command not found' Error After Installing with pip

Encountering the ‘jupyter: command not found’ error after installing Jupyter Notebook with pip can be a frustrating obstacle for data scientists and software engineers embarking on their next analysis project. While seemingly daunting, this error has a readily identifiable cause and a straightforward solution applicable to both Windows and Linux/macOS environments.

In this article, we will explain what causes the “jupyter: command not found” error and provide you with a step-by-step guide on how to fix it either on Windows or Linux/MacOS

Table of Contents

  1. What Causes the “jupyter: command not found” Error?
  2. How to Fix the “jupyter: command not found” Error on Windows
  3. How to Fix the “jupyter: command not found” Error on Linux/macOS
  4. Conclusion

What Causes the “jupyter: command not found” Error?

Before we dive into the solution, let’s first understand what causes the “jupyter: command not found” error. When you install Jupyter Notebook with pip, it installs the Jupyter package and its dependencies in the Python environment. However, it does not add the Jupyter executable to the system’s PATH variable, which is required to run Jupyter Notebook from the command line.

The PATH variable is an environment variable that contains a list of directories separated by a colon. When you type a command in the terminal, the system looks for that command in the directories listed in the PATH variable. If the command is not found in any of those directories, you will get the “command not found” error.

How to Fix the “jupyter: command not found” Error on Windows

Now that we know what causes the “jupyter: command not found” error let’s move on to the solution. There are several ways to fix this error, but we will focus on the most common solution.

Solution: Add Jupyter to the PATH Variable

The first solution is to add the directory containing the Jupyter executable to the PATH variable. Here are the steps to do that:

  1. Open the terminal and type the following command to find the location of the Jupyter executable:

    pip show jupyter
    

    This command will display information about the Jupyter package, including its location. Look for the “Location” field and copy the directory path.

  2. Edit the system’s PATH variable by:

    a. Right-clicking on “This PC” or “My Computer” and selecting “Properties.”

    b. Clicking on “Advanced system settings” and then “Environment Variables.”

    c. In the “System variables” section, select the “Path” variable and click “Edit.”

    d. Click “New” and paste the copied directory path.

  3. Click “OK” to save the changes.

  4. Test if Jupyter Notebook is working by typing the following command:

    jupyter notebook
    

    If Jupyter Notebook opens in your browser, then congratulations, you have fixed the “jupyter: command not found” error.

How to Fix the “jupyter: command not found” Error on Linux/macOS

For Linux/macOS enviornments, the process is a little different. Let’s explore it below:

  1. Open the terminal and type the following command to find the location of the Jupyter executable:

    pip show jupyter
    

Look for the “Location” field and copy the directory path.

  1. Edit the shell profile file (e.g., .bashrc or .zshrc) by typing the following command:

    nano ~/.bashrc
    

    or

    nano ~/.zshrc
    

This will open the profile file in the nano text editor.

  1. Add the following line at the end of the profile file:

    export PATH=$PATH:/path/to/jupyter/executable
    

Replace “/path/to/jupyter/executable” with the directory path you copied in step 1.

  1. Save and exit the profile file by pressing “Ctrl + X,” then “Y,” and finally “Enter.”

  2. Reload the profile file by typing the following command:

    source ~/.bashrc
    

    or

    source ~/.zshrc
    

This will reload the profile file and update the PATH variable.

  1. Test if Jupyter Notebook is now working by typing the following command:

    jupyter notebook
    

If Jupyter Notebook opens in your browser, the ‘jupyter: command not found’ error is resolved.

Additional Hint: Use the Python -m Option

You can try using the Python -m option to run Jupyter Notebook by executing the following command:

python -m notebook

This will run Jupyter Notebook using the Python interpreter. If Jupyter Notebook opens in your browser, then congratulations, you now can run jupyter notebooks.

Conclusion

In this article, we have explained what causes the “jupyter: command not found” error and provided you with solutions to fix it on Windows and Linux/MacOS systems. You can choose the one that works best for your system. With these solutions, you can now enjoy using Jupyter Notebook for your next data analysis project without any errors.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Request a demo today to learn more.