Summary and Setup
Python is a general purpose programming language that is useful for writing scripts to work effectively and reproducibly with data.
For Instructors
If you are teaching this lesson in a workshop, please see the Instructor notes.
Setup
Data
Data for this lesson is from the Portal Project Teaching Database. Specifically, we use the following data files:
Using Python in Jupyterhub
Python is a popular language for scientific computing, and great for general-purpose programming as well.
For this workshop, we will use a web-based Python Environment, JupyterHub, That UCSB Letters and Science IT has setup for us:
Use your UCSB NETID to sign into JupyterHub
If you prefer to use Python on your own computer, you may use the setup instructions below, but this is not required.
Regardless of how you choose to install it, please make sure you have Python installed to version 3.x (e.g., 3.10 is fine and will continue to receive security patches unitl 2026-OCT-04).
Installing Pixi
Select your operating system from the options below.
Open https://pixi.sh/latest/installation/ in your web browser.
Under Installation, select Windows.
Open the Command Prompt, paste the following command, and press Enter.
- Close your Command Prompt window.
Open https://pixi.sh/latest/installation/ in your web browser.
Under Installation, select “Linux & macOS”.
Open the Terminal, paste the following command, and press Return.
If your system doesn’t have curl, you can use wget:
- Close your Terminal window.
Add Python and required libraries
Now that you’ve installed Pixi, we can install Python, JupyterLab, and the required libraries.
- Open your Terminal or Command Prompt. Move to your Desktop folder. There, create a new project with Pixi, which we’ll call python-intro
- Move intro your project and add Python as a dependency of your Pixi project
- Add also JupyterLab and the other required packages
Launch a Jupyter notebook
After installation, in the Terminal or Command Prompt you have open, launch a Jupyter notebook by typing this command:
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.
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.