Welcome soon to be Python user! Python is one of the easiest programming languages to learn and grow with. But there are a few bumps right at the beginning. One of these bumps is to make sure you have Python installed and that it's a sufficiently new version (generally 3.10+ is solid these days).
Because how you install and verify Python varies by operating system, we've put together this short guide. It's goal is to give you exposure to the various ways on your operating system to install and maintain Python in a concise and no-nonsense manner. So with out further ado, let's get you setup!
As mentioned above, how you verify Python and subsequently install it is specific to the operating system. So jump to:
To determine if you have Python installed, open the command prompt or (preferred) install new Windows Terminal from the Microsoft Store.
Verify you have Python, in the command prompt / terminal, type python -V (capital V):
C:\users\username\> python -V
The output should be one of the following (version numbers will vary). C:\users\username> is not typed - Windows displays this as part of the terminal UI.
C:\users\username\> python -V
Python 3.12.0
If you see this and the reported version number is sufficiently high (often 3.9 or higher), you are good to go.
C:\users\username\> python -V
Python 2.7.18
If you have Python 2.*
, then you are using an outdated version of Python. Since 2020, Python 2 has gone entirely unsupported and should not be used. You will need to continue below to install Python 3.
C:\users\username\> python -V
'python' is not recognized as a command or program.
Looks like you do not have Python at all. You will need to continue below to install Python 3. Note that the error message may be slightly different for Windows Terminal: The term python is not recognized as a cmdlet, function, or operable program.
C:\users\username\> python -V
Python was not found; run without arguments to install from the Windows Store...
Looks like you do not have Python at all. You will need to continue below to install Python 3. When you see this specific error message, it means that Python is not installed. What is running is a shim program meant to help you install Python 3 from the Windows Store (one option below). You can select this option by simplifying typing python
and following along in the UI.
So you need to install a new version of Python on your Windows machine. There are a variety of options for doing so. We'll run you through them, but if you are uncertain which one to get, just use the official installer. Keep in mind that no matter how you install Python, you will likely need to close and reopen your terminal/command prompt for any changes to take effect.
- Python Official Installer << recommended
- Windows Store
- Chocolatey Package Manager for Windows
- Anaconda Distribution
The Python official installer can be found on python.org.
Pros
- It's the primary way the Python Software Foundation delivers Python to users
- The installer is supported by core developers working at Microsoft
Cons
- You will not be notified of possible updates
- There is no mechanism to have a new version automatically replace the installed version
Install steps - Windows official installer:
- Visit the downloads page for Windows at python.org
- Find the section entitled Stable Releases
- Download the MSI installer under the Download Windows installer (64-bit) link
- Run the installer - be sure to check the "add python to my path" option
- Close all terminal and command prompt windows
- Run
python -V
in a new terminal window to verify you have Python now working
The Windows Store version of Python is a good option. It's the easiest way to get Python on Windows without administrator permissions. But there are some drawbacks too.
Pros
- Easiest way to get Python on Windows without administrator permissions
- Will keep Python up-to-date automatically within a release version (3.10 updates but not 3.10->3.11)
- Maintained by the core developers who work at Microsoft
Cons
- Does have some minor permission restrictions that apply to all Windows Store apps which can affect your development options
Install steps - Microsoft Store Python:
- Open the Microsoft Store on Windows
- Search for Python
- Find the latest version of Python from Microsoft (currently lists 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12)
- Install from the Microsoft Store
- Close all terminal and command prompt windows
- Run
python -V
in a new terminal window to verify you have Python now working
Chocolatey is a package manager: software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer's operating system in a consistent manner. If you're comfortable using package managers, then this is a good option for you because you can continually update and maintain Python on your system.
Pros
- Will keep Python up-to-date on your system as long as you periodically run the upgrade command
- Will update across versions (e.g. 3.11 -> 3.12)
- Can inform you of pending upgrade if upgrade command is run
Cons
- Complex to use
- Must run as administrator
- Requires separate install of chocolatey itself
Install steps - Chocolatey package manager on Windows
- Install Chocolatey - steps here
- Open an administrator command prompt
- Install the latest Python:
choco install python
- Periodically check for a new release: Open admin command prompt and run
choco upgrade python
- Close all terminal and command prompt windows and reopen one (to refresh the path)
- Run
python -V
in a new terminal window to verify you have Python now working
Anaconda is a distribution of Python that packages many of the common data science packages pre-configured for your system. It is a good option for data scientists.
Pros
- Many packages and libraries are pre-installed
- Good for data science tooling in Python
Cons
- Generally uses conda environments rather than Python's virtual environments - this can lead to a mismatch in instructions when Anaconda is not the primary tool used.
- Packages available here often lag behind in release schedule from PyPI / pip
- Often one whole version behind on Python (e.g. 3.10 rather than 3.11)
Install steps - Anaconda distribution on Windows
- Download the Windows installer
- Run the installer, add Python to path if asked
- Close all terminal and command prompt windows
- Run
python -V
in a new terminal window to verify you have Python now working
To determine if you have Python installed, open the terminal. Verify you have Python: In the terminal, type python3 -V (capital V):
$ python3 -V
The output should be one of the following (version numbers will vary). Do not type $ - macOS displays this as part of the terminal UI.
$ python3 -V
Python 3.12.0
If you see this and the reported version number is sufficiently high (often 3.9 or higher), you are good to go.
If python3
does NOT run successfully, but python
(without the 3) itself does and you see the output:
$ python -V
Python 2.7.18
If you have Python 2.*
, then you are using an outdated version of Python. Since 2020, Python 2 has gone entirely unsupported and should not be used. You will need to continue below to install Python 3.
$ python3 -V
bash: python3: command not found
Looks like you do not have Python 3 at all. You will need to continue below to install Python 3. Note that the error message is slightly different for different shells.
- Homebrew << recommended
- Python Official Installer
- Anaconda distribution
Homebrew is a package manager: software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer's operating system in a consistent manner. If you're comfortable using package managers, then this is a good option for you because you can continually update and maintain Python on your system.
Pros
- Will keep Python up-to-date on your system as long as you periodically run the upgrade command
- Will update across versions (e.g. 3.11 -> 3.12)
- Can inform you of pending upgrade if upgrade command is run
Cons
- Complex to use
- Requires separate install of homebrew itself
Install steps - Homebrew package manager on macOS
- Install Homebrew - steps here
- Open a terminal
- Install the latest Python:
brew install python
- Periodically check for a new release: Open terminal and run
brew update
thenbrew upgrade
- CAREFUL: Take careful note of any messages shown - sometimes you must update your path (varies by default shell: bash, zsh, etc.) for this version to be located.
- Close all terminal windows
- Run
python3 -V
in a new terminal window to verify you have Python now working
The Python official installer can be found on python.org.
Pros
- It's the primary way the Python Software Foundation delivers Python to users
- The installer is supported by core developers
Cons
- You will not be notified of possible updates
- There is no mechanism to have a new version automatically replace the installed version
- Requires admin permissions
Install steps - macOS official installer:
- Visit the downloads page for macOS
- Find the section entitled Stable Releases
- Download the PKG installer under the Download macOS 64-bit universal2 installer link
- Run the installer
- Close all terminal and command prompt windows
- Run
python3 -V
in a new terminal window to verify you have Python now working
Anaconda is a distribution of Python that packages many of the common data science packages pre-configured for your system. It is a good option for data scientists.
Pros
- Many packages and libraries are pre-installed
- Good for data science tooling in Python
Cons
- Generally uses conda environments rather than Python's virtual environments - this can lead to a mismatch in instructions when Anaconda is not the primary tool used.
- Packages available here often lag behind in release schedule from PyPI / pip
- Often one whole version behind on Python (e.g. 3.11 rather than 3.12)
Install steps - Anaconda distribution on Windows
- Download the macOS installer
- Run the installer, add Python to path if asked
- Close all terminal and command prompt windows
- Run
python3 -V
in a new terminal window to verify you have Python now working
To determine if you have Python installed, open the terminal. Verify you have Python, in the terminal, type python3 -V (capital V):
$ python3 -V
The output should be one of the following (version numbers will vary). Don't type $ - Linux displays this as part of the terminal UI.
$ python3 -V
Python 3.12.0
If you see this and the reported version number is sufficiently high (often 3.10 or higher), you are good to go.
If python3
does NOT run successfully, but python
(without the 3) itself does and you see the output:
$ python -V
Python 2.7.18
If you have Python 2.*
, then you are using an outdated version of Python. Since 2020, Python 2 has gone entirely unsupported and should not be used. You will need to continue below to install Python 3.
$ python3 -V
bash: python3: command not found
Looks like you do not have Python 3 at all. You will need to continue below to install Python 3. Note that the error message is slightly different for different shells.
- Package manager << recommended
- Anaconda
- Compiled from source
Note that these instructions are for Ubuntu. With the many variants of Linux, you many need to adjust slightly (e.g. yum vs. apt)
Ubuntu manages it's installed software using apt. This is a good way to install and manage Python 3 on your system.
Pros
- Will keep Python up-to-date on your system as long as you periodically run the upgrade command
- Will update across versions (e.g. 3.11 -> 3.12)
- Can inform you of pending upgrade if upgrade command is run
Cons
- Requires root permissions
- Often lags badly behind the latest version (sometimes about 1.5 years behind)
Install steps - apt package manager on Ubuntu
- Open a terminal
- Update the package sources:
sudo apt update
- Upgrade currently installed software:
sudo apt upgrade
- Install the latest Python 3:
sudo apt install build-essential libssl-dev libffi-dev python3-dev
- Make sure we have pip as part of our Python:
sudo apt install python3-pip
- Close all terminal windows
- Run
python3 -V
in a new terminal window to verify you have Python now working
Anaconda is a distribution of Python that packages many of the common data science packages pre-configured for your system. It is a good option for data scientists.
Pros
- Many packages and libraries are pre-installed
- Good for data science tooling in Python
Cons
- Generally uses conda environments rather than Python's virtual environments - this can lead to a mismatch in instructions when Anaconda is not the primary tool used.
- Packages available here often lag behind in release schedule from PyPI / pip
- Often one whole version behind on Python (e.g. 3.11 rather than 3.12)
Install steps - Anaconda distribution on Ubuntu
- Download the Linux installer
- Run the installer, add Python to path if asked
- Close all terminal and command prompt windows
- Run
python3 -V
in a new terminal window to verify you have Python now working
While we would not generally recommend building Python 3 from source, if you need the very latest on your system, often this is one of the few options available.
Pros
- You'll have the very latest Python you've gotten from source (potentially even pre-release versions)
Cons
- Complicated and fraught with pitfalls
- Can require root permissions for additional build libraries
Install steps - Building python from source on Ubuntu
- Open a terminal
- Ensure your package listings and software are up-to-date:
sudo apt-get update
- Install the build tools:
sudo apt-get install -y build-essential checkinstall
- Add additional libraries needed by Python to build:
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libffi-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
- Change into the src directory:
cd /usr/src
- Get the latest source from python.org/downloads/source and wget it locally, e.g.:
sudo wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
- Decompress it (varies by version):
sudo tar xzf Python-3.12.0.tgz
- Change into the created directory (varies by version):
cd Python-3.12.0
- Prepare it for compilation:
sudo ./configure --enable-optimizations
- Compile it without modifying system Python:
sudo make altinstall
- Verify this version was built (varies by version):
python3.12 --version
- Use
python3.12
instead ofpython
orpython3
commands - Consider creating an alias of
python3.12
topython
in your shell profile.
There is a nice write up of this procedure over here.
If you find a problem or have a suggestion to make this page better, please visit the GitHub repository here. Note that this is not intended for tech support but rather for genuine, broadly applicable improvements to the instructions: