How to Download and Install Python 3
Getting Python installed correctly is the first step to programming in the language. While the process itself is straightforward on every major platform, a few common missteps can cause frustrating errors that stop beginners in their tracks.
This guide covers installation on Windows, macOS, and Linux, walks you through setting up virtual environments, and addresses the most frequent issues you are likely to encounter.
Windows Installation
- Visit python.org/downloads.
- Click the download button for the latest Python 3 release.
- Run the downloaded installer.
Before clicking "Install Now", check the box labeled "Add Python to PATH" at the bottom of the installer window. This is the single most common mistake beginners make, and skipping it causes 'python' is not recognized as an internal or external command errors when you try to use Python from the terminal.
After installation, open Command Prompt and verify:
python --version
Expected output:
Python 3.12.4
If you see a version number, Python is installed and configured correctly.
macOS Installation
macOS may include an outdated system Python, but you should install a current version using Homebrew, the standard macOS package manager.
First, install Homebrew if you do not have it already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install Python:
brew install python
Verify the installation:
python3 --version
Expected output:
Python 3.12.4
On macOS, use python3 instead of python to ensure you are running the Homebrew-installed version rather than any system Python that may be present.
Linux Installation (Ubuntu/Debian)
Most Linux distributions include Python, but it may not be the latest version. The Deadsnakes PPA provides current Python releases for Ubuntu and Debian-based systems:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12 python3.12-venv
For Fedora and RHEL-based distributions:
sudo dnf install python3.12
Verify the installation:
python3.12 --version
Expected output:
Python 3.12.4
Setting Up Virtual Environments
Once Python is installed, the next important step is learning to use virtual environments. A virtual environment creates an isolated space for each project's dependencies, preventing conflicts between projects that require different versions of the same package.
Creating a Virtual Environment
python -m venv .venv
This creates a .venv directory in your current folder containing a self-contained Python installation.
Activating the Virtual Environment
The activation command differs by platform:
# Windows (Command Prompt)
.venv\Scripts\activate
# Windows (PowerShell)
.venv\Scripts\Activate.ps1
# macOS / Linux
source .venv/bin/activate
Your terminal prompt will change to show (.venv) at the beginning, confirming the environment is active:
(.venv) C:\Users\you\project>
Installing Packages
With the virtual environment activated, install packages using pip:
pip install requests pandas
These packages are installed only inside the virtual environment, not system-wide.
Deactivating
When you are finished working on the project, deactivate the environment:
deactivate
Never install packages globally with pip install outside of a virtual environment. Doing so can create version conflicts between projects and may even break system tools that depend on specific package versions. Virtual environments keep every project self-contained and reproducible.
Running Your First Script
Verify that everything works by creating and running a simple Python script:
- Create a file named
hello.pywith the following content:
import sys
print("Hello from Python!")
print(f"Version: {sys.version}")
- Open your terminal and navigate to the directory where you saved the file:
cd Desktop
- Run the script:
python hello.py
Expected output:
Hello from Python!
Version: 3.12.4 (main, Jun 6 2024, 18:26:44) [MSC v.1940 64 bit (AMD64)]
If you see output similar to this, Python is installed and working correctly.
Troubleshooting Common Issues
"Python is not recognized" (Windows)
This error occurs when Python is not in your system PATH.
Solution 1: Re-run the Python installer, select "Modify", and make sure "Add Python to environment variables" is checked.
Solution 2: On Windows 10 and 11, the operating system may redirect the python command to the Microsoft Store. To fix this, search for "Manage App Execution Aliases" in Windows Settings and disable the Python app installers listed there.
SSL Certificate Errors (macOS)
If pip fails with certificate verification errors after a fresh Python installation from python.org:
# Navigate to Applications > Python 3.x folder
# Double-click "Install Certificates.command"
# Or run it from the terminal:
/Applications/Python\ 3.12/Install\ Certificates.command
This installs the required SSL certificates that pip needs to download packages securely.
Permission Denied Errors (Linux)
If you see permission errors when installing packages, do not use sudo pip install. Instead, use a virtual environment (the recommended approach) or the --user flag:
pip install --user package_name
Using sudo pip install modifies system-level Python packages, which can break your operating system's own tools and scripts.
Multiple Python Versions Installed
When you have multiple Python versions installed side by side, be explicit about which version you want to use:
# Specify the version directly
python3.12 -m venv .venv
# On Windows, use the py launcher
py -3.12 -m venv .venv
# Check which Python the 'python' command points to
python --version
python3 --version
Recommended Next Steps
After installation, these tools will improve your development experience:
| Tool | Purpose |
|---|---|
| VS Code | Popular free code editor with an excellent Python extension |
| pip | Package installer for Python (included with Python) |
| venv | Virtual environment manager (included with Python) |
| pyenv | Tool for managing multiple Python versions on one system |
Conclusion
The critical points to remember are: on Windows, always check "Add Python to PATH" during installation. On macOS and Linux, use package managers (Homebrew and apt/dnf) rather than downloading installers manually. Always work within virtual environments to keep your projects isolated and your system Python clean. Once these fundamentals are in place, you are ready to start building with Python.