Introduction
Encountering the error message 'jupyter' is not recognized as an internal or external command can be frustrating, especially when you want to work on your data analysis or development tasks.
Understanding the Problem
In the above command, the main issue is that the system cannot locate the Jupyter executable. This typically happens when Jupyter is either not installed correctly or its installation path is not included in the system's PATH environment variable.
Solutions
1. Install Jupyter using pip
If Jupyter is not installed, you can install it using pip.
Sample output:
It will install the Jupyter itself with all the necessary dependencies.
2. Verify installation
Don't panic if the error message 'jupyter' is not recognized as an internal or external command still exists. It's because it cannot be found in the PATH environment variables. So let's move ahead to the next step:
3. Add Jupyter to the PATH environment variables
(a) Locate Jupyter Installation Directory
You may use pip show jupyter to check whether the Jupyter Notebook is installed properly in your local machine.
From here, we know that Jupyter is installed successfully and its actual location.
(b) Add new variable under System Variables
Search "environment variables" in your local machine.
In the System Properties, click on the "Environment Variables" button.
Under System Variables, find the PATH variable, and click "Edit".
Add the file path for "Jupyter" execution. In my case:
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311
and
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts
you can use `pip show Jupyter` to first find where the Jupyter is downloaded. Then, take the path to its parent directory and add to the PATH environment variables. This is because the parent directory consists of `Scripts` directory which contains `pip.exe` and `jupyter.exe` that is required to run `jupyter notebook`.
Make sure these two variables are added and close the environment variables.
you must restart your command prompt shell to reflect the changes.
(c) Open your command prompt and verify the usage
Run Jupyter notebook command and now it's working!
From the output, you can find the url where you can access your Jupyter Notebook.
(a) Locate Jupyter Installation Directory
If you are not sure about where Jupyter installation happens, you can open the command prompt use the 'which' command to locate it.
which jupyter will display complete path to jupyter executable.
(b) Modify Shell Configuration File
Open `.bashrc` (for bash) or `.zshrc` (for zsh) in a text editor:
Add the following line at the end of the file:
This command will add the Jupyter installation directory to your PATH.
Then, save and exit the editor.
For ‘nano`, you may press ‘CTRL+0’, then press ‘Enter’ to save and then exit your editor.
(c) Verify Jupyter installation
jupyter notebook
If your jupyter notebook runs without any error, then you have successfully added jupyter to your PATH.
4. Fix the Error using Official Installer
If the above solutions do not solve the issue, you may solve this problem through adding Python to the PATH using an official installer.
If you did install Python previously, start the installer and click on "Modify".
(b) Add the python.exe to your PATH environment variables.
When you install it, make sure you tick the "Add python.exe to PATH"
If you have installed it before, you can modify:
First, click the "Modify" button.
Next, click the "Next" button. In the "Advanced Options", make sure to tick "Add Python to environment variables". Lastly, click the "Install button".
Finally, Python will be installed and configured properly in the PATH environment variables and so the error 'jupyter' is not recognized as an internal or external command will be resolved.
Conclusion
The 'jupyter' is not recognized as an internal or external command error is a common issue that can be resolved by either installing Jupyter correctly or updating the system's PATH environment variable. If both the methods cannot solve the issue, you can also re-install / modify Python installation to add the `python.exe` and `jupyter.exe` to the PATH environment variables. By following the solutions outlined above, you can quickly get back to your work without further interruption. Hope you enjoy and happy coding!