How to Check Python Version on Windows, Mac and Linux
Before you install a package, follow a tutorial, or fix a bug, you need to know which version of Python is actually running on your computer. Different versions behave differently: a feature that works in Python 3.12 may not exist in Python 3.8, and a library that needs Python 3.10 or later will simply refuse to install on an older release. Checking takes about ten seconds, and it saves hours of confusing errors later.
This guide shows how to check Python version on Windows, Mac, and Linux, how to check it from inside a Python script, how to see the versions used by different tools, and what to do when the command does not work at all. No extra software is needed: every method below uses tools that are already on your system.
Quick Answer: How to Check Python Version
Open a terminal or Command Prompt and type python --version or python3 --version, then press Enter. The computer prints a line such as Python 3.12.4. That is your version. On Windows, use python --version first. On Mac and Linux, use python3 --version first, because python alone often points to the old Python 2 or to nothing at all.
| System | Command to try first | Command to try second |
|---|---|---|
| Windows | python –version | py –version |
| Mac | python3 –version | python –version |
| Linux | python3 –version | python –version |
| Inside Python | import sys; print(sys.version) | python -c “import sys; print(sys.version)” |
How to Check Python Version on Windows
Windows is the system where people most often run into two Pythons at once: one from the Microsoft Store, one from python.org, or one bundled with another program. These steps find the one your terminal actually uses.
- Press Win + R, type
cmd, and press Enter to open Command Prompt. You can also open PowerShell or Windows Terminal. - Type
python --versionand press Enter. You should see something likePython 3.12.4. - If that says Python was not found, try
py --version. Thepylauncher is installed with Python from python.org and can find the newest version for you. - To see exactly where Python lives, type
where pythonorwhere py. The path tells you whether you are using the Microsoft Store version, a python.org install, or an Anaconda install. - To list every version the launcher knows about, type
py -0p. You can then run a specific one, for examplepy -3.11 --version.
If Command Prompt says ‘Python’ is not recognised as an internal or external command, Python is installed but not on your PATH, or it is not installed at all. Reinstall Python from python.org and tick Add python.exe to PATH during setup, or use the Microsoft Store version, which sets itself up automatically. Close and reopen the terminal after installing, because a terminal that was already open will not see the change.

How to Check Python Version on Mac
Every modern Mac ships with a Python, but it is not the one you should use for your own projects. Apple includes a system Python for its own tools, and it is usually an older version. You need to check the version you installed yourself.
- Open Terminal from Applications, then Utilities, or press Cmd + Space and type Terminal.
- Type
python3 --versionand press Enter. A typical answer isPython 3.12.4orPython 3.13.0. - Type
which python3to see the path. If it says/usr/bin/python3, that is Apple’s system Python. If it says/opt/homebrew/bin/python3, that is the Homebrew version, and if it says/usr/local/bin/python3, it came from python.org or another installer. - If you use Homebrew, type
brew list python@3.12orbrew info pythonto see which versions Homebrew has installed.
Do not delete or replace Apple’s system Python. macOS tools depend on it, and removing it can break the system. Instead, install your own Python with Homebrew (brew install python) or from python.org, and always call it with python3. If python without the 3 gives you Python 2.7, that is normal on older Macs and is not a problem, as long as python3 works.
How to Check Python Version on Linux
Linux distributions also ship a system Python, and the exact commands vary a little between Ubuntu, Debian, Fedora, and Arch, but the basic check is the same everywhere.
- Open a terminal with Ctrl + Alt + T or from your applications menu.
- Type
python3 --versionand press Enter. - Type
which python3andls /usr/bin/python*to see every Python binary on the system. - On Ubuntu or Debian, type
apt list --installed | grep python3to see the installed Python packages and their versions. - On Fedora, type
dnf list installed python3, and on Arch, typepacman -Q python.
On Linux, never remove the system Python or change the default python3 link by hand, because the package manager and desktop tools depend on it. If you need a newer version than your distribution provides, install it alongside the system one with a tool such as pyenv, deadsnakes on Ubuntu, or a package from python.org, and call it by its full version name, for example python3.12. Our guide to how to check your Ubuntu version is useful here, because the Python version available in Ubuntu’s repositories depends on which Ubuntu release you are running.
How to Check Python Version Inside a Script or Notebook
Sometimes the terminal and your project use different Pythons. A virtual environment, a notebook, or an editor can all point somewhere else. Checking from inside Python itself tells you the truth for that project.
- Start Python by typing
python3in a terminal, or open a Python file in your editor. - Run
import sysand thenprint(sys.version). The output includes the version number, the build date, and the compiler. - For just the number, run
print(sys.version_info)orimport platform; print(platform.python_version()). - From the command line without opening Python, run
python3 -c "import sys; print(sys.version)". - In Jupyter, run a cell containing
import sys; print(sys.version)to see the version that notebook kernel is using.
If the version inside your editor is different from the version in your terminal, your editor is using a different interpreter. In VS Code, click the Python version in the bottom right corner and choose the interpreter you want. In PyCharm, go to Settings, then Project, then Python Interpreter, and pick the right one. Once you know which Python each tool uses, set up a good editor: our roundup of the best Python IDEs compares the main options, from VS Code and PyCharm to lighter editors.
Python 2 vs Python 3: Why the Command Matters
Python 2 reached the end of its life in 2020, and Python 3 is the only version that receives updates. Even so, many computers still have a python command that points to Python 2, especially older Macs and Linux systems. That is why the version check matters: running python --version and seeing Python 2.7.18 does not mean you have no Python 3, only that python is the old name.
| Command | Usually means | What to use instead |
|---|---|---|
| python | Python 2 on older systems; Python 3 on newer Windows installs | python3 on Mac and Linux |
| python3 | Python 3 | Use this everywhere for new work |
| py | Python launcher on Windows | py -3.12 to pick a version |
| python3.12 | Exactly Python 3.12 | Use when several versions are installed |
If a tutorial tells you to run python and it fails or gives the wrong version, try python3 with the same arguments. The code is the same; only the command name changes. On Windows, you can also use py -3 to force the launcher to use Python 3.
How to Check the Version of a Package and of pip
Knowing the Python version is only half the story. A library may need a newer Python, or pip itself may be out of date. Check both before you install anything.
- Check pip with
pip --versionorpython3 -m pip --version. The output shows the pip version and the Python version it belongs to, which is a useful cross-check. - Check a package with
pip show numpy, replacing numpy with the package name. The output shows its version and where it is installed. - List all packages with
pip listorpython3 -m pip list. - Check a package from inside Python with
import numpy; print(numpy.__version__).
Always use python3 -m pip rather than plain pip when you have more than one Python installed, because pip on its own may belong to a different Python than the one you are using. If pip is missing, install it with python3 -m ensurepip on most systems, or your package manager on Linux.
Troubleshooting: When the Version Check Fails
| Problem | Likely cause | Fix |
|---|---|---|
| ‘python’ is not recognised | Python not on PATH, or not installed | Reinstall with Add to PATH ticked, or use py on Windows |
| python gives 2.7, python3 gives 3.x | Old python command still points to Python 2 | Use python3; do not delete the system Python |
| Terminal and editor show different versions | Editor uses a different interpreter or virtual environment | Change the interpreter in the editor settings |
| Version is older than a tutorial needs | System Python is old | Install a newer Python alongside it; do not replace the system one |
| pip installs to the wrong Python | pip belongs to another Python | Use python3 -m pip instead of pip |
If you work on Linux, the same terminal skills help in other jobs too: our guide to how to rename a directory in Linux covers the basic commands you will use alongside Python every day.
Frequently Asked Questions
What is the command to check Python version?
Type python --version on Windows or python3 --version on Mac and Linux, then press Enter. The computer prints the version, for example Python 3.12.4.
How do I check Python version in VS Code?
Look at the Python version shown in the bottom right corner of VS Code, or open the terminal inside VS Code and run python --version. Click the version in the corner to change interpreters.
How do I know if I have Python 2 or Python 3?
Run python --version and python3 --version. If the first says 2.7 and the second says 3.x, you have both. Use Python 3 for all new work.
How do I update Python to the latest version?
Download the latest installer from python.org, or use Homebrew on Mac (brew upgrade python) or your package manager on Linux. Installing a new version does not remove the old one, so check the version again after installing.
Why does python –version not work on my Mac?
On many Macs, python is not set up, or it points to the old Python 2. Use python3 --version instead, which is the command for the Python 3 you installed.
Conclusion
Checking your Python version is a ten-second habit that prevents most version problems before they start. On Windows, run python --version; on Mac and Linux, run python3 --version; and inside a script, use sys.version to see exactly which Python that project is using. If the number is older than the tutorial or library needs, install a newer Python alongside the system one rather than replacing it. Write the version down when you start a project, and check it again whenever something that used to work suddenly stops.
[…] directory is not executable, you cannot reach it. If you are learning Python on Linux, our guide on how to check the Python version will help you confirm which Python your scripts will use, and our guide on how to format an SSD […]
[…] you are new to Python, start by confirming your setup with our guide on how to check the Python version on your computer, so you know which Python your bot will run […]
[…] are still setting up Python, first check which version you have installed by following our guide on how to check the Python version on Windows, Mac and Linux, because the behaviour described here works the same in Python 3, which is the version you should […]