Jupyter Notebook Installation | Beginner's Guide
What is Jupyter Notebook?
Jupyter Notebook is a web-based interactive computing environment, which can be imagined as an intelligent notebook:
- Take notes: Record text, formulas, and images like using Word.
- Write and run code: Directly write Python code in cells, click run to see results instantly.
- Show results: Charts and data tables generated by code will be displayed directly in the notebook.
Jupyter Notebook is particularly suitable for data cleaning, statistical analysis, machine learning model training, and visualization, as you can complete all work including code, results, and explanations in a single document.
Preparation Before Installation: Python Environment
Jupyter Notebook itself is written in Python, so the prerequisite for installation is having Python and the package manager pip installed on your computer.
1. Check if Python is Installed
Open your command line tool:
- Windows: Search
cmdorCommand Promptin the Start menu. - macOS: Open
Applications->Utilities->Terminal. - Linux: Use the shortcut
Ctrl + Alt + Tto open the terminal.
In the opened command window, enter the following command and press Enter:
python --version
or
python3 --version
If you see a version number like Python 3.8.10 (important: the version must be 3.3 or higher), Python is already installed.
2. Check if pip is Installed
pip is Python's software installation manager, usually included when installing Python. Check with the following command:
pip --version
or
pip3 --version
If version information appears, pip is already installed.
3. If Python is Not Installed
If your computer doesn't have Python yet, don't worry - installation is straightforward.
Recommended method: Visit the Python official website to download the latest stable version (e.g., Python 3.11.x). During installation, make sure to check the "Add Python to PATH" option to avoid manual environment variable configuration later. Then install like regular software by clicking Next all the way through.
After installation, repeat steps 1 and 2 above to confirm success.
Install Jupyter Notebook Using pip
Once Python and pip are ready, installing Jupyter Notebook requires just one command.
In your command line tool, enter:
pip install jupyter
Command explanation
pip: Invokes Python's package manager.install: Tells pip you want to install something.jupyter: The package name to install.
After pressing Enter, you'll see the command line start downloading and installing Jupyter Notebook and its components.
Note: If you're using macOS or Linux, or encounter permission issues, you may need to use pip3 or add sudo (macOS/Linux) before the command:
pip3 install jupytersudo pip install jupyter(will require your computer password)
If installation is slow, use a domestic mirror:
pip3 install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple
Verify Installation Success
After installation, check Jupyter's version to ensure everything works:
jupyter --version
If version information like jupyter core : 5.8.1 appears, installation was successful!
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 encounter a zsh: command not found: jupyter error, it means the zsh terminal hasn't loaded Jupyter's environment variables. Solution:
- First verify Jupyter installation success by running
pip3 show jupyter. If version info appears, installation succeeded. - Execute
echo 'export PATH="$HOME/Library/Python/3.x/bin:$PATH"' >> ~/.zshrc(replace 3.x with your actual Python version, e.g., 3.9). - Run
source ~/.zshrcto refresh configuration. Thenjupyter notebookshould work. If not, restart the terminal and try again.
Install Jupyter Notebook Using Anaconda
Anaconda is a Python data science environment management tool that includes the Python interpreter, Jupyter Notebook, and commonly used data analysis third-party libraries (like Pandas, NumPy). One-step installation handles all dependencies without additional configuration.
Using Anaconda to install everything at once reduces version conflicts that may occur during manual library installation.
- Anaconda Tutorial:
- Anaconda Official Website: https://anaconda.org/
Steps
1. Download Anaconda: Visit the Anaconda official website to download the installer suitable for your operating system (Windows, macOS, Linux).
2. Install: Run the downloaded .exe or .pkg file. During installation, it's recommended to check "Add Anaconda to my PATH" (though not officially recommended, this makes command line startup easier for beginners).
3. Verify Anaconda Installation: After installation, open the system command prompt (Windows) or terminal (macOS/Linux), and enter:
conda --version
If a version number like conda 23.10.0 appears, installation was successful.
4. Launch Jupyter Notebook: Open Anaconda Navigator (available in the Start menu on Windows, or Launchpad on macOS). The interface will show Jupyter Notebook. Click the Launch button, and the Jupyter Notebook interface will automatically open in your default browser after a few seconds.
You can also enter the command in the command prompt/terminal:
jupyter notebook
After pressing Enter, success message will appear:
Your default web browser (e.g., Chrome, Firefox) will automatically open a new page at http://localhost:8888, which is the Jupyter Notebook dashboard:
YouTip