How To Fix "Jupyter: Command Not Found" After Pip Install?

Published August 1, 2024

Problem: Jupyter Command Not Found After Installation

The "Jupyter: Command Not Found" error happens after installing Jupyter using pip. This problem stops users from starting Jupyter Notebook or Jupyter Lab from the command line, even though the installation seemed to work.

Verifying Jupyter Installation

Checking Pip Installation Status

To check if Jupyter is installed on your system, use pip to list the installed packages. Open your terminal and run this command:

pip list

This command shows all Python packages installed on your system. Find "jupyter" in the list. If it's there, Jupyter is installed.

You can also check for a specific Jupyter package with:

pip show jupyter

This command gives information about the Jupyter package, including its version and install location.

If you use Python 3, you might need to use pip3:

pip3 list
pip3 show jupyter

These commands help you check if Jupyter is installed and give information about its installation status.

Tip: Use pip freeze for a clean output

If you want a cleaner output of installed packages without version numbers, you can use the following command:

pip freeze | grep jupyter

This will list all installed packages that contain "jupyter" in their name, making it easier to spot Jupyter-related packages.

Resolving the "Command Not Found" Issue

Updating PATH Environment Variable

The PATH environment variable tells your operating system where to find executable files. When you run a command, your system checks the directories listed in PATH for that command.

To add Jupyter's installation directory to PATH:

  1. Find Jupyter's installation location:

    pip show jupyter | grep Location
  2. Open your shell configuration file (e.g., ~/.bashrc, ~/.zshrc) in a text editor.

  3. Add this line at the end, replacing [JUPYTER_LOCATION] with the path from step 1:

    export PATH="$PATH:[JUPYTER_LOCATION]/bin"
  4. Save the file and restart your terminal or run:

    source ~/.bashrc

Tip: Check Your Current PATH

To view your current PATH, open a terminal and run:

echo $PATH

This shows all directories in your PATH, separated by colons. Make sure Jupyter's location is included.

Using Python Module to Launch Jupyter

If updating PATH doesn't work, you can start Jupyter using Python:

For Python 3:

python3 -m notebook

For Python 2:

python -m notebook

This method bypasses the need for the 'jupyter' command to be in your PATH.

For Jupyter Lab, use:

python3 -m jupyterlab

These commands start Jupyter directly through Python, avoiding PATH-related issues.