ZMedia Purwodadi

How to Install Pandas & NumPy in Jupyter Notebook

Table of Contents



Ever felt that buzz of excitement to start a data science project, only to get stuck before writing a single line of code? I’ve been there. You’re ready to analyze a cool dataset, build a machine learning model, or just practice your Python skills, but first, you need to get your tools ready. The foundation of almost every data project in Python is built on two powerful libraries: Pandas and NumPy. And the best place to use them? Often, it's the flexible and interactive Jupyter Notebook.

If the process of how to install Pandas & NumPy in Jupyter Notebook feels confusing, you've landed in the right place. Consider this your friendly, step-by-step walkthrough. By the end of this guide, you'll have everything installed, verified, and ready for your data adventures. No prior setup knowledge is needed I'll walk you through it all.

What We're Installing and Why

Before we jump into the commands, let's quickly understand why these tools are so essential. Think of them as your data science toolkit:

  • NumPy is the foundation. It's all about working with arrays and matrices of numbers. It's incredibly fast and provides the mathematical backbone for everything else. When you need to perform complex calculations, NumPy is the engine under the hood.

  • Pandas builds on top of NumPy. It gives you these amazing data structures called DataFrames (think of them like super-powered Excel spreadsheets in your code). Pandas is your go-to for data cleaning, manipulation, and analysis.

  • Jupyter Notebook is your workspace. It's a web-based environment where you can write code, see the output immediately, and add notes all in one place. It's perfect for experimentation and storytelling with data.


You typically install Jupyter first to create your workspace, and then install Pandas and NumPy within that environment. Let's get your environment set up!

How to Install Jupyter Notebook On Windows

The easiest way to get started, especially if you're on a Windows machine, is by ensuring you have Python and pip (Python's package installer) ready to go.

Prerequisite: Check for Python and Pip

First, let's see if Python is already on your system.

  1. Open your Command Prompt (Press the Windows key, type cmd, and hit Enter).

  2. Type the following and press Enter:

python --version


  1. or sometimes it's 

python3 --version


If you see a version number (e.g., Python 3.11.4), you're good to go! If you get an error, you'll need to download Python.


  • How to download Python: Head over to python.org, download the latest version for Windows, and run the installer. Crucially, make sure you check the box that says "Add Python to PATH" before installing. This makes your life much easier.

The Simple Pip Install Method

Once Python is confirmed, installing Jupyter Notebook is a one-line command. Back in your Command Prompt, type:


pip install jupyterlab

This command fetches the Jupyter software from the internet and installs it on your computer. jupyterlab is the next-generation version of Jupyter Notebook and is highly recommended, but if you prefer the classic interface, pip install notebook works just as well.


The process for how to install Jupyter Notebook in Windows 11 is exactly the same as for Windows 10. The Command Prompt hasn't gone anywhere!


Command Prompt terminal on a Windows desktop showing the pip install command for Jupyter Lab, demonstrating how to install Jupyter Notebook in Windows.

How To Install Pandas and NumPy

Now for the stars of the show. You have two main paths to install Pandas and NumPy, and both are straightforward.

Method 1: Install Everything at Once (The Efficient Way)

When you run the pip install jupyterlab command, you can actually add Pandas and NumPy to the same line. This installs all three in one go and is my preferred method for a quick setup.


pip install jupyterlab pandas numpy

Just like that, you've installed your entire core data science environment. Easy, right?

Method 2: Install Them Later from Inside Jupyter

Maybe you already have Jupyter running. No problem! You can install packages directly from inside a notebook cell. This is a handy trick to know.

  1. First, launch Jupyter Notebook from your Command Prompt:



This will open a new tab in your web browser.

  1. Create a new Python notebook.

  2. In the first cell, type and run the following command by pressing Shift+Enter:

!pip install pandas numpy

The exclamation mark ! tells Jupyter to run this as a shell command. Once it's done, you're all set!

Putting It All Together: A Quick Test Drive

Let's make sure everything is working in harmony. The best way to do that is with a little test code.

  1. In your Jupyter notebook, create a new cell.

  2. Copy and paste the following code block:

# Importing our newly installed libraries
import pandas as pd
import numpy as np


# Let's check their versions
print("Pandas version:", pd.__version__)
print("NumPy version:", np.__version__)


# A quick NumPy demo: creating an array


my_array = np.array([1, 2, 3, 4, 5])
print("My NumPy array:", my_array)
print("Mean of the array:", my_array.mean())


# A quick Pandas demo: creating a DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [24, 31, 28]}
my_dataframe = pd.DataFrame(data)
print("\nMy Pandas DataFrame:")
print(my_dataframe)

Run the cell.

If you see an output that shows the version numbers, a NumPy array, and a neat little table (a DataFrame), then congratulations! You have successfully figured out how to install Pandas & NumPy in Jupyter Notebook.


Jupyter Notebook interface showing a successful test of the Pandas and NumPy installation, with code and output visible.

Troubleshooting Common Hiccups

Sometimes things don't go perfectly on the first try. Here are solutions to common issues:

  • pip is not recognized: This usually means Python isn't in your system PATH. Re-run the Python installer from python.org and double-check the "Add to PATH" box.

  • Permission Errors: If you're on a shared machine or using certain setups, you might need to use the --user flag:

pip install --user jupyterlab pandas numpy

  • Installation Takes Forever or Fails: This can be due to a slow internet connection or a busy package server. You can try using Python's built-in venv (virtual environment) for a cleaner setup, which is a great next step to learn once you're comfortable with the basics.

Wrapping Up

And there you have it! You've now set up a professional data science environment on your own computer. Knowing how to install Pandas & NumPy in Jupyter Notebook is a fundamental skill that unlocks a world of possibilities in data analysis, machine learning, and scientific computing.

The hardest part is now over. 


The fun part working with data is just beginning.

What was your experience like? Did this guide help you get set up, or did you run into a different challenge? Let me know in the comments below I read every one and love helping out.


If you found this guide helpful, feel free to share it with a friend who's also getting started. And if you want more content like this from beginner tutorials to advanced data science deep dives check out the other articles on my blog or explore my Jupyter Notebook playlist on YouTube. Happy coding

\

Post a Comment