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.
The Python official installer can be found on python.org.
Pros
Cons
Install steps - Windows official installer:
python -V
in a new terminal window to verify you have Python now workingThe 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
Cons
Install steps - Microsoft Store Python:
python -V
in a new terminal window to verify you have Python now workingChocolatey 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
Cons
Install steps - Chocolatey package manager on Windows
choco install python
choco upgrade python
python -V
in a new terminal window to verify you have Python now workingAnaconda 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
Cons
Install steps - Anaconda distribution on Windows
python -V
in a new terminal window to verify you have Python now workingTo 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 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
Cons
Install steps - Homebrew package manager on macOS
brew install python
brew update
then brew upgrade
python3 -V
in a new terminal window to verify you have Python now workingThe Python official installer can be found on python.org.
Pros
Cons
Install steps - macOS official installer:
python3 -V
in a new terminal window to verify you have Python now workingAnaconda 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
Cons
Install steps - Anaconda distribution on Windows
python3 -V
in a new terminal window to verify you have Python now workingTo 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.
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
Cons
Install steps - apt package manager on Ubuntu
sudo apt update
sudo apt upgrade
sudo apt install build-essential libssl-dev libffi-dev python3-dev
sudo apt install python3-pip
python3 -V
in a new terminal window to verify you have Python now workingAnaconda 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
Cons
Install steps - Anaconda distribution on Ubuntu
python3 -V
in a new terminal window to verify you have Python now workingWhile 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
Cons
Install steps - Building python from source on Ubuntu
sudo apt-get update
sudo apt-get install -y build-essential checkinstall
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libffi-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
sudo tar xzf Python-3.12.0.tgz
cd Python-3.12.0
sudo ./configure --enable-optimizations
sudo make altinstall
python3.12 --version
python3.12
instead of python
or python3
commandspython3.12
to python
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: