Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Jupyter Notebook Installation

Jupyter Notebook Installation

Jupyter Notebook is aweb-based interactive computing environment; you can think of it as a smart notebook:

Jupyter Notebook is especially well suited fordata cleaning, statistical analysis, machine learning model training and visualization, because you can finish code, results and explanations of your thinking all in one document.


Before installing: the Python environment

Jupyter Notebook itself is written in Python, so the prerequisite is that Python and its package manager are already installed on your computer pip.

1. Check whether Python is installed

Open yourcommand line tool:

In the command line window, type the following command and press Enter:



python --version

or



python3 --version

If you see a version number output like Python 3.8.10 such as this (important: the version must be 3.3 or newer), then Python is already installed.

2. Check whether pip is installed

pip is Python's software installer, usually bundled with Python; check it with:

pip --version

or



pip3 --version

Likewise, if you see version information, then pip is also ready.

3. If Python is not installed

If your computer does not have Python yet, do not worry, installation is very simple.

Recommended method: visit the Python official websiteand download the latest stable version (such as Python 3.11.x). When downloading,be sure to check Add Python to PATH, which saves you from configuring environment variables manually later. Then just click Next like any ordinary software install.

After installation, repeat steps 1 and 2 above to confirm success.


Install Jupyter Notebook with pip

Once Python and pip are ready, installing Jupyter Notebook takes just one command.

In your command line tool, enter:



pip install jupyter

Command breakdown:

After pressing Enter, the command line starts downloading and installing Jupyter Notebook and its related components.

Note: If you are on macOS or Linux, or run into permission problems, you may need to use pip3 or prefix the command with sudo (macOS/Linux):

  • pip3 install jupyter
  • sudo pip install jupyter (you will be asked for your computer password)
  • If installation is slow, use a local mirror:

    pip3 install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple

    Verify the installation: after installation, run the following command to check the Jupyter version and make sure everything is correct:

    
    
    jupyter --version
    
    

    If version information appears, for example jupyter core : 5.8.1, the installation succeeded!

    Selected Jupyter core packages...
    
    IPython          : 8.18.1
    
    ipykernel        : 6.31.0
    
    ipywidgets       : 8.1.8
    
    jupyter_client   : 8.6.3
    
    jupyter_core     : 5.8.1
    
    jupyter_server   : 2.17.0
    
    

    If you see a problem like zsh: command not found: jupyter , the reason is that the zsh terminal has not loaded Jupyter's environment variables. Solution:

    • 1. First verify that Jupyter is installed by entering pip3 show jupyter; if version information appears, the installation succeeded.
    • 2. Run echo 'export PATH="$HOME/Library/Python/3.x/bin:$PATH"' >> ~/.zshrc (replace 3.x with your actual Python version, such as 3.9).
    • 3. Enter source ~/.zshrc to refresh the configuration, then enter jupyter notebook to start it; if it still does not work, restart the terminal and try again.

    • Install Jupyter Notebook with Anaconda

      Anaconda is a Python data science environment manager that bundles the Python interpreter, Jupyter Notebook and commonly used third-party libraries for data analysis (such as Pandas and NumPy); one install handles all dependencies with no extra configuration.

      Anaconda sets up the whole environment in one step, reducing version conflicts that can occur when installing libraries manually.

      Step

      **1. Download Anaconda:** visit the Anaconda official siteand download the installer for your operating system (Windows, macOS, Linux).

      2. Run the installer: launch the downloaded .exe or .pkg file. During installation it is advisable to check Add Anaconda to my PATH (although the official docs do not recommend it, it makes launching from the command line much easier for beginners).

      3. Verify the Anaconda installation: after installation, open Command Prompt (Windows) or Terminal (macOS/Linux) and enter:

      conda --version
      
      

      If a version number appears (such as conda 23.10.0), the installation succeeded.

      1. Start Jupyter Notebook: open Anaconda Navigator (find it in the Start menu on Windows or Launchpad on macOS); the interface shows Jupyter Notebook, click the Launch button, and after a few seconds the Jupyter Notebook interface opens automatically in your default browser.

      You can also enter the following command in Command Prompt / Terminal:

      jupyter notebook
      
      

      After pressing Enter, a successful startup message appears:

      Your default web browser (such as Chrome or Firefox) automatically opens a new page, usually at http://localhost:8888; this is the Jupyter Notebook dashboard: