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.
Find Cmder, which we set up before, and run it.
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.
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.
That's it, you're good to go!
Another option is to use the Start Menu to open up Add and Remove Programs. Scroll down to find anything starting with Python.
If you find any, it might make sense to uninstall them now. I've especially had issues with old Python versions fighting new Python versions on Windows.
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. To do that we need to install some software that allows us to install software from the command line
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:
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.
We'll be installing Scoop from https://scoop.sh/. The front page isn't perfect, so I'll just copy the directions here:
- Use the Start Menu to open up Windows PowerShell. It's another command line! Windows is crazy!
- Copy and paste
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserinto PowerShell and press enter. - It will ask you if you want to change the "Execution policy." Type
Yand hit enter. - Copy and paste
irm get.scoop.sh | iexinto PowerShell and press enter.
Confirm it worked
To confirm Homebrew was installed, type the following command to check the documentation for the brew command.
Did it work? Great, you're good to go.
Installing uv¶
Now we'll use Homebrew or Scoop to install uv, which is the tool we'll use to install and manage Python.
If you're getting an error when installing software with scoop, try reading the scoop issues page.
Confirm it worked
To confirm uv was installed correctly, run the following command to ask for its version number.
If it prints anything other than "command not found" you're good to go.
Installing Python¶
There are all kinds of different Python versions out there. We're going to use Python 3.13, which is new enough to be current but old enough that most data analysis packages should work well with it.
uv protects the Python it installs, so we'll make a shared "environment" named lede where we'll have our own special Python. We'll also tell your command line to activate it automatically whenever you open a new window.
Creating your Python environment¶
Run these commands in Cmder, not PowerShell. Cmder uses user_profile.cmd as its startup file, kind of like macOS uses ~/.zshrc.
uv venv %USERPROFILE%\.venvs\lede --python 3.13 --seed
if not exist "%CMDER_ROOT%\config" mkdir "%CMDER_ROOT%\config"
type nul >> "%CMDER_ROOT%\config\user_profile.cmd"
findstr /C:"\.venvs\lede\Scripts\activate.bat" "%CMDER_ROOT%\config\user_profile.cmd" >nul || echo call "%USERPROFILE%\.venvs\lede\Scripts\activate.bat" >> "%CMDER_ROOT%\config\user_profile.cmd"
call "%USERPROFILE%\.venvs\lede\Scripts\activate.bat"
python -m ensurepip --default-pip
You should see (lede) at the beginning of your command line. That means you're using your new special Python environment.
Confirm it worked
Open a new command line and run the following commands:
The first command should print Python 3.13.something. The second command should mention .venvs and lede – if it doesn't work, try pip3 instead of pip.
Installing packages¶
If you come across some code on the internet that asks you to "install a package" using pip install XXXX, you're now good to go. For example, if you want to install pandas, you just use the following code:
I said "You're now good to go" but... you might not be. You can try
pip3 install pandasinstead ifuvis being picky.
And everything should work great.
You're all set!¶
Congrats!