Install Python on Windows, macOS, and Linux
Python runs on every major operating system, and installing it is the first concrete step toward building anything from automation scripts to production backend services. This guide covers the official, recommended installation methods for Windows, macOS, and Linux. It also walks through verifying the installation, understanding Python versions, creating a minimal virtual environment, and troubleshooting common problems. By the end, you will have a clean, modern Python setup ready for professional development.
Before You Install​
Take a moment to understand what you are installing and what to avoid.
Choose Python 3​
All active Python development happens on Python 3. Python 2 reached end of life in January 2020 and receives no security fixes. Any tutorial, book, or tool that still recommends Python 2 should be treated as outdated. Install the latest stable Python 3 release available for your platform.
What You Are Installing​
A standard Python installation provides three core components:
- Python interpreter – the program that reads and executes your
.pyfiles. - pip – the package installer for Python. It fetches libraries and tools from the Python Package Index (PyPI).
- Virtual environment support – the
venvmodule creates isolated environments so that each project can manage its own dependencies independently.
Familiarity with these three pieces is enough to begin productive work.
Where to Get Python​
Always download Python from the official website at python.org/downloads. Third-party repackagers may bundle outdated versions, add unwanted tooling, or modify system paths in ways that are difficult to reverse. On Linux, the distribution package manager is also a valid source, provided you understand which version it supplies.
Installing Python on Windows​
Download Python​
Visit python.org/downloads and click the button for the latest Python 3 release. The website detects your operating system and offers the appropriate installer. Choose the Windows installer (64-bit) unless you have a specific reason to use the 32-bit version.
Run the Installer​
Launch the downloaded executable. Before clicking “Install Now”, check the box labeled Add Python to PATH. This option updates your system’s PATH environment variable so that the python and pip commands are available from any terminal window. Leaving this unchecked is the most common cause of “python is not recognized” errors later.
Select Install Now for the default installation, which includes the interpreter, pip, documentation, and the standard library. If your organization enforces restricted installation locations, you may need to choose “Customize installation” and adjust the install directory, but for personal development machines the defaults are correct.
Verify Installation​
Open a new Command Prompt or PowerShell window. Run the following commands and confirm that the output shows the version you installed:
python --version
pip --version
Both should print a version number without errors. If the commands are not found, the most likely cause is that the “Add Python to PATH” option was missed. In that case, re-run the installer, choose “Modify”, and enable the option, or add the Python installation directory and its Scripts subdirectory to PATH manually through System Environment Variables.
Installing Python on macOS​
System Python vs. Development Python​
macOS ships with a system Python installation that is used by the operating system itself. It may be an older version, and modifying or replacing it can break system tools. Always install a separate Python interpreter for development work and leave the system Python untouched.
Install Using the Official Package​
Download the macOS installer from python.org/downloads. Open the .pkg file and follow the installation steps. The installer places the interpreter in /usr/local/bin and adjusts your shell profile so that the newly installed python3 command is available in the terminal.
Verify Installation​
Open a new Terminal window and run:
python3 --version
pip3 --version
On macOS, the commands are python3 and pip3 to avoid shadowing the system’s python command. The output should reflect the version you just installed. If you see an older version, check that /usr/local/bin appears early in your PATH by running echo $PATH. Reordering the PATH variable or restarting the terminal usually resolves any conflicts.
Installing Python on Linux​
Most Linux distributions include Python 3 in their official package repositories. The exact package name and version depend on the distribution and release cycle. Prefer your distribution’s package manager for system-wide installations, as it integrates cleanly with other system components.
Ubuntu / Debian​
Update the package list and install Python 3 along with pip and the venv module:
sudo apt update
sudo apt install python3 python3-pip python3-venv
On some older LTS releases, the packaged Python version may lag behind the latest upstream release. For most development tasks this is acceptable. If you need a bleeding-edge version, consider using the deadsnakes PPA or building from source, but be aware that these approaches require more maintenance.
Fedora / RHEL​
Fedora ships relatively recent Python releases. Install with:
sudo dnf install python3 python3-pip
On RHEL and CentOS systems, enable the epel-release repository first if needed. The command python3 will invoke the installed interpreter.
Arch Linux​
Arch provides the latest stable Python release in the core repository:
sudo pacman -S python python-pip
Verify Installation​
Regardless of distribution, verify the installation by running:
python3 --version
pip3 --version
If pip3 is not found but python3 works, install the pip package using your distribution’s package manager as shown above. Some distributions separate pip into an optional package to keep base installations minimal.
Verify Your Installation​
A thorough verification goes beyond version checks. Confirm that your interpreter runs, imports work, and that you can create and run a small script.
Check the Interpreter​
Launch the interactive interpreter by typing python (or python3 on macOS/Linux) in your terminal. You should see a >>> prompt with the Python version printed at the top. Type exit() or press Ctrl+D to leave.
Run a Small Script​
Create a file named hello.py with the following content:
print("Hello, PythonDevPro!")
Run it from the terminal:
python hello.py
If the message prints, your Python installation and PATH configuration are working correctly. This test also confirms that your terminal can find the interpreter and execute scripts—a workflow you will use daily.
Check pip​
Verify that pip can query the package index:
pip list
This command lists installed packages. A fresh installation shows only pip and setuptools. If you see permission errors, confirm that you are using a user-level installation or a virtual environment rather than attempting to install packages globally as root.
Understanding Python Versions​
Python versions follow a major.minor.micro scheme (for example, 3.12.4). The major version is 3 for all modern releases. The minor version introduces new features and language changes on a predictable annual cadence. Micro releases contain bug fixes and security patches.
Which Version to Use​
Install the latest stable release. Each new minor version brings performance improvements, better error messages, and features that make development more productive. Production systems often standardize on a specific minor version, but for learning and personal projects, staying current is the best policy.
Version Compatibility​
Code written for Python 3.10 generally runs unchanged on 3.11 and 3.12. Breaking changes are documented in release notes and are rare in practice. Tools like pyenv (covered in a separate guide) allow you to switch between versions when you need to test against a specific runtime.
Installing pip​
pip is included with official Python installations from python.org and with most distribution-packaged Python versions on Linux. Before attempting a manual installation, verify that it is already present:
pip --version
If pip is missing, download the bootstrap script from https://bootstrap.pypa.io/get-pip.py and run it with your Python interpreter. This script is maintained by the Python Packaging Authority and is the recommended fallback.
pip is the gateway to the Python ecosystem. Every library, framework, and tool you will use—from FastAPI to pytest—is installed through it. Learning to use pip effectively is as important as learning the language itself.
Creating Your First Virtual Environment​
Virtual environments isolate project dependencies so that different projects can use different library versions without conflict. Create one for every new project.
Navigate to your project directory and run:
python -m venv .venv
This command creates a .venv directory containing a self-contained Python environment. Activate it:
- Windows (Command Prompt):
.venv\Scripts\activate - Windows (PowerShell):
.venv\Scripts\Activate.ps1 - macOS / Linux:
source .venv/bin/activate
After activation, your terminal prompt changes to show the environment name. Any python or pip commands now operate inside this isolated space. Install packages, run scripts, and experiment without affecting the system Python or other projects.
Deactivate the environment with the deactivate command when you are done working on that project.
Virtual environments are a fundamental practice, not an optional extra. The Understanding Virtual Environments in Python article covers them in detail.
Common Installation Problems​
Even with official installers, environment misconfigurations happen. Here are the most frequent issues and how to resolve them.
“python is not recognized” (Windows)​
The Python installation directory and its Scripts subdirectory are not in your PATH. Re-run the installer, select “Modify”, and ensure “Add Python to PATH” is checked. Alternatively, add the directories manually through System Environment Variables. Restart your terminal afterward.
“command not found: python3” (macOS/Linux)​
The interpreter is either not installed or its location is not on your PATH. Verify installation with your package manager and check the path of the interpreter with which python3. If it is installed but not found, add its directory to your shell profile.
Multiple Python Versions Installed​
Developers often end up with Python versions from different sources: system Python, a manual installer, a package manager, and perhaps a tool like pyenv. Use which python or where python to see which interpreter your terminal resolves. On macOS/Linux, ls -l $(which python3) shows the actual binary location and reveals whether it is a symlink to a version manager.
Permission Errors When Installing Packages​
Running pip install without a virtual environment may attempt to write to system directories and fail with permission errors. Always work inside a virtual environment for project dependencies. If you must install a tool globally, use the --user flag to install into your user site-packages directory.
Wrong Interpreter Selected in the IDE​
IDEs like VS Code and PyCharm may pick up a different Python installation than the one you intend to use. After creating a virtual environment, explicitly select the interpreter inside .venv from the IDE’s Python interpreter settings. This ensures that linting, debugging, and terminal integration all target the correct environment.
Accidentally Using System Python​
On macOS, typing python invokes the system Python 2 interpreter on older versions of the OS, or a stub that prompts you to install developer tools. Always use python3 and pip3 on macOS unless you are inside an activated virtual environment, where python and pip are unambiguous.
Recommended Development Tools​
A clean Python installation pairs well with a few essential tools.
- VS Code – lightweight, extensible editor with excellent Python support through the Python and Pylance extensions. PythonDevPro has a dedicated VS Code setup guide.
- PyCharm – full-featured IDE with deep code analysis, database tools, and integrated test runners. The Community Edition is free and sufficient for most development.
- Terminal – your primary interface for running scripts, managing environments, and interacting with Git. Invest time in learning your shell well.
- Git – version control is not optional for professional work. Install Git from git-scm.com or your package manager and initialize repositories from the first line of code.
These tools, combined with a correctly installed Python interpreter, form the foundation of a professional development setup.
Best Practices​
- Always use a supported Python 3 release; avoid Python 2 entirely.
- Keep your Python installation updated with the latest micro releases for security and bug fixes.
- Create a dedicated virtual environment for every project, no exceptions.
- Verify your installation after setup by checking versions and running a simple script.
- Avoid installing packages globally unless you are installing a standalone tool that you need across projects.
- Initialize a Git repository at the start of every project, even personal ones.
What’s Next​
With Python installed and verified, you are ready to set up a complete development environment and start learning the language in depth.
- Python Learning Roadmap – a structured path from fundamentals to production engineering.
- Understanding Virtual Environments in Python – a deeper look at isolating dependencies and managing project environments.
- Python Foundations – master the core language: data structures, functions, OOP, and type hints.
- Modern Python Project Structure – learn how to organize a professional Python codebase.
Pick the article that matches your next goal, or follow the roadmap sequentially for a guided progression through the handbook.