Python for Data course menu
Install NumPy, pandas, matplotlib and Jupyter (Windows, macOS, Linux)
Set up Python for data analysis: install the libraries with pip in a virtual environment or get everything at once with Anaconda, start Jupyter, and check that your installation works.
On this page
You need Python 3.10 or newer plus a handful of libraries. There are two common ways to install them. Pick one.
Option 1: pip and a virtual environment#
If Python is already installed (see Installing Python), create a virtual environment for your data projects so their libraries stay separate from everything else, then install the libraries into it.
On Windows (Command Prompt or PowerShell):
py -m venv data-env
data-env\Scripts\activate
pip install numpy pandas matplotlib seaborn scipy jupyterlab openpyxlOn macOS and Linux:
python3 -m venv data-env
source data-env/bin/activate
pip install numpy pandas matplotlib seaborn scipy jupyterlab openpyxlopenpyxl lets pandas read and write Excel files. When the environment is active, your prompt starts with (data-env); run deactivate to leave it, and the activate command again whenever you come back.
Option 2: Anaconda#
Anaconda is a Python distribution that comes with all of these libraries and Jupyter already installed, plus the Anaconda Navigator app for launching tools. Download the installer for your system from anaconda.com, run it with the default options, and open Anaconda Prompt (Windows) or a new terminal (macOS/Linux).
Anaconda is a large download, but it avoids installing packages one by one, which is why many data courses and universities use it. Check Anaconda's licence terms on their site if you use it inside a large organisation.
Check that everything works#
Run this in Python (or in a notebook):
import numpy as np
import pandas as pd
import matplotlib
import scipy
print("NumPy", np.__version__)
print("pandas", pd.__version__)
print("matplotlib", matplotlib.__version__)
print("SciPy", scipy.__version__)NumPy 2.3.5
pandas 2.3.3
matplotlib 3.10.6
SciPy 1.16.3Your version numbers may be newer; that is fine. If you see ModuleNotFoundError: No module named 'pandas', the library is not installed in the Python you are running: activate your environment (or open Anaconda Prompt) and install it there.
The conventional import names#
Every data scientist imports the libraries with the same short names. Use them too, so your code looks like everyone else's:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as snsStart Jupyter#
With the environment active, start JupyterLab from the folder where your data files live:
jupyter labIt opens in your web browser. The next lesson explains how notebooks work.
Common mistakes#
Key takeaway#
Next: Jupyter Notebooks.
Finished this lesson?