11 Installing Python
11.1 Introduction
So far in our learning sequence, you’ve been working mostly in Google Colab, a convenient, cloud-based environment for running Python code. Now it’s time to tackle working locally on your own machine. This allows you to work offline and gives you more control over your development environment.
We’ll guide you through installing Python 3.12.0 to ensure compatibility with the examples and exercises we’ll cover. Let’s get started!
Before we proceed, we’ll split the instructions into two tracks:
- Windows Users
- macOS Users
Please follow the instructions specific to your operating system.
11.2 Windows Users
11.2.1 Step 1: Check Your Current Python Version
- Search for “Command Prompt” in your start menu.
- Into the terminal window type
python --version
and press Enter. - If Python is installed, it will display the version number.
- If you already have version 3.12.0 installed, you can skip the rest of the steps. If you have any other version (higher or lower), proceed to the next step to install 3.12.0.
11.2.2 Step 2: Download Python 3.12.0
- Open your web browser.
- Go to Google and search for “Python 3.12.0”.
- In the search results, find the link to python.org that mentions Python 3.12.0.
- Scroll down to the bottom of the Python 3.12.0 page to find the “Windows installer (64-bit)”. Then click on the link to download the installer.
11.2.3 Step 3: Install Python
- Locate the downloaded file (usually in your Downloads folder).
- Double-click the installer to run it.
- Important: Check the box that says “Add Python 3.12 to PATH” at the bottom of the installer window.
- If you have the option, also elect to use admin privileges.
- At the end you may be asked whether to disable path length limit. Click yes to this too.
- Wait for the installation to finish.
11.2.4 Step 4: Verify the Installation
- Close your old command prompt window if it is still open.
- In your start menu, again search for “Command Prompt” and open a new terminal window.
- Type
python --version
and press Enter. - You should see
Python 3.12.0
. (You may see a newer version if you already had Python on your computer. That’s okay. From our IDE, we will be able to select the correct version of Python that we just installed.)
11.2.5 Step 5: Run Python Locally
- In Command Prompt, type
python
and press Enter. - At the
>>>
prompt, type2 + 2
and press Enter. - You should see
4
. - Type
exit()
and press Enter.
Yay! You’ve successfully installed Python and you ran your first local Python command.
11.3 macOS Users
11.3.1 Step 1: Check Your Current Python Version
- Go to Applications > Utilities > Terminal.
- Type
python3 --version
and press Return. - If Python is installed, it will display the version number.
- You may get a pop-up asking to install command line developer tools if you do not have them. Go ahead and accept and install that.
- If your computer does not have Python installed, you will get an error.
- Otherwise, you should see a version number.
- If you already have version 3.12.0 installed, you can skip the rest of the steps. If you have any other version (higher or lower), proceed to the next step to install 3.12.0.
11.3.2 Step 2: Download Python 3.12.0
- Open your web browser.
- Go to Google and search for “Python 3.12.0”.
- In the search results, find the link to python.org that mentions Python 3.12.0.
- Ensure the URL is from www.python.org to avoid unofficial sources.
- Scroll down to the bottom of the Python 3.12.0 page.
- Under the “Files” section, find “macOS 64-bit universal2 installer”.
- Click on the link to download the installer.
11.3.3 Step 3: Install Python 3.12.0
- Locate the downloaded file (usually in your Downloads folder).
- Double-click the installer to run it.
- Wait for the installation to finish.
- Click “Close” once the installation is complete.
11.3.4 Step 4: Verify the Installation
- Close your old terminal window if it is still open.
- Again go to Applications > Utilities > Terminal.
- Type
python3 --version
and press Return. - You should see
Python 3.12.0
.
11.3.5 Step 5: Run Python Locally
- In Terminal, type
python3
and press Return. - At the
>>>
prompt, type2 + 2
and press Return. - You should see
4
. - Type
exit()
and press Return.
Yay! You’ve successfully installed Python 3.12.0 on your Mac and you ran your first local Python command.