Intro to Python & JupyterLab
Setting Up Your Environment
Before you can start building computational notebooks, you need to set up Python and JupyterLab on your computer. These instructions will guide you through the process.
Setting Up Python
First, you’ll install Python.
Python is an open source project, which means that there are several Python distributions to choose from. This course will use the Python distribution from python.org, the official website for the Python programming language.
Note: The official version of Python is also known as CPython. This name comes from its implementation in C and C++ (as are many other programming languages and operating systems).
The processes for setting up Python differ among operating systems, so these instructions cover doing so on Windows, macOS, and Linux.
Setting Up Python on Windows
If you’re on Windows, the simplest way to install Python on your system is to use python.org’s Windows installer.
Download the Windows installer from python.org and launch it. You’ll see this opening screen:
To avoid the problem where Windows can’t find Python, check these two checkboxes at the bottom of the installer’s opening screen:
- Use admin privileges when installing py.exe
- Add python.exe to PATH
Once you’ve checked those boxes, click Install Now to start the installation process.
Once the process is complete, confirm that Python was installed correctly on your computer by launching PowerShell and then entering the following in PowerShell’s command-line interface:
py --version
Note: If you’re not familiar with PowerShell, you can launch it by pressing Windows+r, entering
powershell
in the pop-up window that appears, and clicking the OK button.
You should receive a single-line response immediately below the line where you entered py --version
that looks something like this where y
can be any number:
Python 3.12.y
If you get a response like this, Python has been installed on your computer, and you can proceed to the next section, Installing JupyterLab.
Setting Up Python on macOS
If you’re on macOS, the simplest way to install Python on your system is to use python.org’s macOS installer.
Download the macOS installer from python.org, launch it, and start the installation process.
Once the process finishes, follow the instructions on the final screen of the installer:
Note: This Python needs a set of SSL root certificates to verify the identity of a secure network connection. You can download and install a current curated set from the Certifi project by double-clicking the Install Certificates icon in the Finder window. See the ReadMe file for more information.
Follow these instructions by opening the Applications folder. Find and open the Python 3.12 folder inside that folder. You’ll see something like this:
Double-click the item named Install Certificates.command. It’ll open a Terminal window and run, displaying a stream of messages that should include something similar to the following at or near the end:
Successfully installed certifi-202x.y.z
Finally, you confirm that Python was installed correctly on your computer by launching Terminal and then entering the following in Terminal’s command-line interface:
python3 --version
If the code above gives you an error, try entering python --version
instead.
You should receive a single-line response immediately below the line where you entered python3 --version
or python --version
that looks something like this where y
can be any number:
Python 3.12.y
If you get a response like this, Python has been installed on your computer, and you can proceed to the next section, Installing JupyterLab.
Setting Up Python on Linux
If you’re using Linux, first check if your system already has a recent enough version of Python. Any version from 3.10 and later should suffice for this course.
Open a terminal and enter the following command to see if Python is on your system, and if so, which version:
python --version
If the above gives you an error, try entering this command instead:
python3 --version
In either case, you should receive a single-line response immediately below the line where you entered that looks something like this:
Python 3.x.y
If the response is something like Python 3.x.y
where x
is 10
or greater, Python has been installed on your computer, and you can proceed to the next section, Installing JupyterLab.
Installing JupyterLab
Next, you’ll install JupyterLab with pip
, Python’s command-line package installer.
Install JupyterLab by running the following command on the command line (Windows PowerShell on Windows or Terminal on macOS and Linux):
pip install jupyterlab
If you’re on macOS or Linux and the above command didn’t work, try replacing pip
with pip3
.
The installation process will generate many messages. If it doesn’t end with an error message, your system should be properly set up for this course.
Confirm that JupyterLab was installed by using pip
to list the currently installed packages. Enter the following on the command line:
pip list
pip
will list all the installed packages. If one of the items in the list is jupyterlab
and its version is 4.2.0 or later, JupyterLab is set up on your computer and you can proceed to the next step in this lesson.