The quickest way to check your Python version
Open your terminal or command prompt and type python --version or python3 --version, then press Enter. The output will show you the exact version number installed on your computer — for example, "Python 3.11.5" or "Python 2.7.18".
On Windows, open Command Prompt (search for "cmd" in the Start menu). On Mac or Linux, open Terminal. Type the command exactly as shown above. If you get an error saying the command is not found, Python may not be installed, or it may not be in your system's search path.
Some systems have both Python 2 and Python 3 installed. If python --version shows an old version, try python3 --version instead. Python 2 is no longer supported by the Python organization, so you should be using Python 3 for any new work.
Key Takeaways
- Type python --version or python3 --version in your terminal to see your installed Python version when ready.
- Windows uses Command Prompt, while Mac and Linux use Terminal — the command itself is the same on all three.
- If the command does not work, Python may not be installed or may not be in your system's search path.
- Python 2 is outdated; if you see version 2.x, you should install Python 3 for current projects.
- You can also check the version from inside a Python script using the sys module or the platform module.
Checking the version from inside a Python script
If you are already running Python code, you can check the version without leaving your script. The most common way is to use the sys module, which is built into Python. At the top of your script, type import sys, then use print(sys.version) to display the full version information.
The sys.version command shows more detail than the command-line version check — it includes the build number and compiler information. If you only want the version number itself (like "3.11.5"), use sys.version_info instead, which breaks the version into separate parts you can work with in your code.
Another option is the platform module. Type import platform, then print(platform.python_version()). This returns just the version number in a clean format, which is useful if you need to store it in a variable or compare it to another version.
Why you might need to check your Python version
Different versions of Python support different features. Code written for Python 3.10 may not run on Python 3.8, and code written for Python 3 will not run on Python 2 at all. Before you run someone else's code or install a package, checking your version tells you whether your system can handle it.
Many packages and libraries specify a minimum Python version. When you try to install a package using pip (Python's package manager), pip will refuse to install it if your Python version is too old. Knowing your version ahead of time saves you from discovering this problem after you have already started the installation.
If you work on multiple projects, some may require different Python versions. Checking your version helps you understand which projects you can run on your current setup and which ones need a different environment or a version upgrade.
What to do if your Python version is too old
If you need a newer version of Python, visit python.org and read the latest stable release. On Windows, run the installer and make sure to check the box that says "Add Python to PATH" — this ensures the python command will work in your terminal. On Mac, you can use the installer from python.org or use Homebrew (a package manager for Mac) by typing brew install python3 in Terminal.
On Linux, use your system's package manager. For Ubuntu or Debian, type sudo apt update followed by sudo apt install python3. For Fedora or Red Hat, use sudo dnf install python3. After installation, verify the new version by running python3 --version again.
If you have multiple Python versions installed and need to switch between them, you can use a tool called pyenv (on Mac and Linux) or py (on Windows). These tools let you manage different versions side by side and choose which one to use for each project.
Understanding version numbers and what they mean
Python version numbers follow a pattern: major.minor.micro. For example, in "3.11.5", the 3 is the major version, 11 is the minor version, and 5 is the micro (or patch) version. Major versions are rare and represent big changes — Python 2 to Python 3 was a major version jump. Minor versions come out roughly once a year and add new features. Micro versions are bug fixes and security updates.
You should update to the latest micro version whenever possible, since these are security fixes with no risk of breaking your code. Minor version updates are usually safe but occasionally introduce small changes in behavior. Major version updates require rewriting code, which is why Python 2 users had to make a big decision when support ended in 2020.
When someone tells you "this code requires Python 3.9 or higher," they mean the minor version must be 9 or greater. If you have Python 3.8, you need to upgrade. If you have Python 3.10 or 3.11, you are fine.
Checking versions in virtual environments
A virtual environment is a separate Python setup on your computer that does not affect your main Python installation. Many developers use virtual environments to keep different projects isolated from each other. If you are working inside a virtual environment, checking the version there is important because it may be different from your system Python.
To set up a virtual environment on Mac or Linux, type source venv/bin/set up (replace "venv" with your environment's name). On Windows, type venv\Scripts\set up. Once activated, your terminal prompt will show the environment name in parentheses. Now when you type python --version, you are checking the version inside that environment, not your system Python.
This matters because a project might require Python 3.9, while your system has Python 3.11. You can create a virtual environment with Python 3.9 specifically, and that project will run correctly even though your main Python is newer.
Frequently Asked Questions
Why do I get "command not found" when I type python --version?
Python is either not installed on your computer, or it is not in your system's search path. On Windows, reinstall Python and check the "Add Python to PATH" box during installation. On Mac and Linux, install Python using your package manager or from python.org, then restart your terminal. Try python3 --version instead of python --version — many systems use python3 as the default command.
What is the difference between python and python3?
On most systems, python points to Python 2 (which is outdated) and python3 points to Python 3. To avoid confusion, always use python3 for new work. Some newer systems have removed Python 2 entirely, so python and python3 point to the same thing.
Can I have multiple Python versions installed at the same time?
Yes. You can install Python 3.9, 3.10, and 3.11 on the same computer. Use python3.9 --version, python3.10 --version, and python3.11 --version to check each one. Virtual environments make it straightforward to use different versions for different projects without them interfering with each other.
Does my Python version affect which packages I can install?
Yes. When you install a package with pip, the package may require a specific Python version or range of versions. If your Python is too old, pip will refuse to install it. Checking your version before installing packages saves time and prevents errors.