Summary and Setup

Python is a general purpose programming language that is useful for writing scripts to work effectively and reproducibly with data.

Prerequisite

For Instructors

If you are teaching this lesson in a workshop, please see the Instructor notes.

Prerequisite

Installing Python and JupyterLab using Pixi

Python is a popular language for scientific computing, and great for general-purpose programming as well. Installing all of the scientific packages we use in the lesson individually can be a bit cumbersome, and therefore recommend using Pixi by prefix.dev.

Regardless of how you choose to install it, please make sure you install Python version 3.x (e.g., 3.10 is fine and will continue to receive security patches unitl 2026-OCT-04).

Discussion

Installing Pixi

Select your operating system from the options below.

  1. Open https://pixi.sh/latest/installation/ in your web browser.

  2. Under Installation, select Windows.

  3. Open the Command Prompt, paste the following command, and press Enter.

BASH

powershell -ExecutionPolicy ByPass -c "irm -useb https://pixi.sh/install.ps1 | iex"
  1. Close your Command Prompt window.
  1. Open https://pixi.sh/latest/installation/ in your web browser.

  2. Under Installation, select “Linux & macOS”.

  3. Open the Terminal, paste the following command, and press Return.

BASH

curl -fsSL https://pixi.sh/install.sh | sh

If your system doesn’t have curl, you can use wget:

BASH

wget -qO- https://pixi.sh/install.sh | sh
  1. Close your Terminal window.

Add Python and required libraries


Now that you’ve installed Pixi, we can install Python, JupyterLab, and the required libraries.

  1. Open your Terminal or Command Prompt. Move to your Desktop folder. There, create a new project with Pixi, which we’ll call python-intro

BASH

cd ~/Desktop
pixi init python-intro
  1. Move intro your project and add Python as a dependency of your Pixi project

BASH

cd python-intro
pixi add python
  1. Add also JupyterLab and the other required packages

BASH

cd python-intro
pixi add jupyterlab pandas numpy matplotlib

Launch a Jupyter notebook


After installation, in the Terminal or Command Prompt you have open, launch a Jupyter notebook by typing this command:

BASH

pixi run jupyter lab

The notebook should open automatically in your browser. If it does not or you wish to use a different browser, open this link: http://localhost:8888.

Prerequisite

Leave terminal used to launch Jupyter open

Jupyter depends on a server running in the background associated with the window used to launch it. Closing that window will results in web interface errors in the web interface. When done, you can either close the terminal or shut down the server using CTRL+C and submitting y within 5 seconds if the terminal is needed for other tasks.

For a brief introduction to Jupyter Notebooks, please consult our Introduction to Jupyter Notebooks page.