Skip to content

Installing and setting up Python

Warning

If you run into problems using the command line, you might want to take a look at troubleshooting on the command line.

Having trouble with uv?

This page uses uv to install Python. If uv is causing problems, try the pyenv version of these instructions instead.

Prerequisites

Open the command line

First, you'll want to open up the command line.

Click the magnifying glass to open up Spotlight, then search for Terminal. Run it.

Open Windows Terminal, which we set up to use Git Bash. Make sure it says UCRT64 (or MINGW64) somewhere, not PS C:\!

Previously installed Pythons

You can run the following command exactly as it is written below to list all of the Pythons your command line can see.

which -a python

If it says something like python not found, congratulations! You have zero Pythons installed!

The first one in the list is the one that's used when python is typed.

This is just for reference: copy and paste the results somewhere. If we run into problems later, it might help us figure out what's going on.

If you see anaconda or miniconda anywhere in there, take a look at removing Anaconda before you continue.

Otherwise, you're good to go!

Use the Start Menu to open up Add or Remove Programs. Scroll down to find anything starting with Python or Anaconda.

If you find any, uninstall them now. I've especially had issues with old Python versions fighting new Python versions on Windows.

If which -a python mentions WindowsApps, don't worry! That's a fake Python that Windows uses to send you to the Microsoft Store. Our new Python will take its place.

Package manager

One way to install software on your computer is to download software. Another way is to run commands on the command line, which uses a tool called a package manager.

Since we think the command line is cool, we're going to use that technique.

We'll be installing Homebrew from https://brew.sh/. They have a long line of text on their homepage that you cut and paste into Terminal, but to make your life easy I've reproduced it here:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

It might ask for your password by saying something like Password: []. Type your computer password and press enter.

If you type and type and nothing shows up... I promise, just type your password and hit enter! The command line is hiding your typing from anyone who might be looking at your screen.

When it's done, Homebrew might tell you to run a couple more commands under Next steps. If it does, copy and paste them in, too!

Good news: Windows comes with a package manager called winget, so there's nothing to install!

Confirm it worked

To confirm Homebrew was installed, type the following command to check the documentation for the brew command.

brew help

Did it work? Great, you're good to go.

To confirm winget is ready to go, ask it for its version number.

winget --version

If it prints a version number, you're good to go. If it says command not found, open the Microsoft Store, search for App Installer, and install or update it.

Installing uv

Now we'll install uv, which is the tool we'll use to install and manage Python.

brew install uv
winget install --id=astral-sh.uv -e --source winget

It might ask you to agree to some terms. Type Y and hit enter. When it says Successfully installed, you're done.

Installing uv with winget

Don't leave off the --source winget part! Without it, winget also searches the Microsoft Store. On computers with an older version of winget – brand-new laptops that haven't updated yet, or school and work laptops where the Store is locked down – that fails with an error about a "server certificate."

Close your command line and open up a new one.

Confirm it worked

To confirm uv was installed correctly, run the following command to ask for its version number.

uv --version

If it prints anything other than "command not found" you're good to go.

Installing Python

We're going to use Python 3.14 for this setup. Use the version in the commands below, even if you see a newer one available. A newer Python can arrive before the packages we need are ready for it, especially if its version includes a, b, or rc (a preview release).

The screenshots may show an older Python version. Follow the written commands and look for 3.14.something when checking your own install.

uv protects the Python it installs, so we'll make a shared "environment" named data where we'll have our own special Python. This is where the packages you install for these tutorials will live. We'll also tell your command line to turn it on automatically whenever you open a new window.

Creating your Python environment

Already have a data environment with a different Python version? Follow Upgrading or downgrading your Python version.

Copy and paste these commands into your command line. Be sure to hit enter after the last one!

uv venv ~/.venvs/data --python 3.14 --seed
touch ~/.zshrc
grep -qxF 'source "$HOME/.venvs/data/bin/activate"' ~/.zshrc || echo 'source "$HOME/.venvs/data/bin/activate"' >> ~/.zshrc
source ~/.zshrc

The first line makes the environment, the next two add a line to ~/.zshrc – the file that runs every time you open Terminal – to turn the environment on, and the last one runs that file right now.

uv venv ~/.venvs/data --python 3.14 --seed
[ -f ~/.bash_profile ] || echo '[ -f ~/.bashrc ] && . ~/.bashrc' > ~/.bash_profile
grep -qxF 'source "$HOME/.venvs/data/Scripts/activate"' ~/.bashrc 2>/dev/null || echo 'source "$HOME/.venvs/data/Scripts/activate"' >> ~/.bashrc
grep -qxF 'export PYTHONUTF8=1' ~/.bashrc || echo 'export PYTHONUTF8=1' >> ~/.bashrc
source ~/.bashrc

The first line makes the environment. The next few add lines to ~/.bashrc – the file that runs every time you open Git Bash – to turn the environment on and to make Python use UTF-8 when reading and writing files. The last one runs that file right now.

When you paste, nothing happens until you press Enter. Then it'll download Python and set everything up. (It'll suggest a command that starts with Activate with: – you can ignore that, we've already taken care of it.)

Creating the data environment in Git Bash

You should see (data) at the beginning of your command line. That means you're using your new special Python environment. On Windows, (data) shows up on its own line, right above the student@computer line.

If the first line says A virtual environment already exists, check its Python version before continuing. An existing environment does not automatically switch versions when you install another Python. If it is not 3.14, follow Upgrading or downgrading your Python version.

Confirm it worked

Close your command line and open up a new one. You should see (data) at the beginning of it automatically.

Now run each of these commands:

which python
python --version
python -m pip --version
  • which python should mention .venvs/data. This is the most important one!
  • python --version should print Python 3.14.something. Note that the command is python, space, hyphen, hyphen, version (it gets mistyped a lot!).
  • python -m pip --version should also mention .venvs and data.

If which python says something else – Anaconda, WindowsApps, .pyenv, /usr/bin – then some other Python is getting in the way. Take a look at removing Anaconda, or bring the output of which -a python to class.

On Windows, it should look something like this:

Confirming Python on Windows

Installing packages

We used uv to set up Python, and we'll also use it to install packages. With (data) active, install pandas like this:

uv pip install pandas

Confirm it worked

Run this command to ask Python which pandas it found:

python -c "import pandas; print(pandas.__file__)"

It should print a path with .venvs and data in it.

Checking where pandas was installed

If another tutorial says pip install pandas, you can use uv pip install pandas here. The command is uv pip install, with all three words. It installs into your active data environment.

We kept --seed when creating the environment so ordinary pip commands, including %pip install inside a notebook, work too. If you need pip directly, use python -m pip install pandas to make sure it belongs to the Python you are using.

What if something breaks?

If an install fails with Failed to build or Could not build wheels, start by checking python --version. If it is a preview release or a different version from this guide, try switching to Python 3.14. You can also test a package with another Python version before replacing your main environment.

If you need a completely fresh environment, the same replacement steps work even if you are keeping the same Python version. Save your package list first, then reinstall the packages you need.

You're all set!

Congrats! 🎉

Next up: install Jupyter.