How to Check Python Version: Commands for Windows, macOS & Linux

| Summary: Python version numbers such as 3.13.5 identify the major, minor, and patch releases, which can affect project and package compatibility. A quick version check can prevent errors caused by using the wrong interpreter, especially when multiple installations or virtual environments exist. Commands like python –version and python3 –version make this check take only seconds. |
Python is widely used for web development, data analysis, automation, artificial intelligence, and many other tasks. If you are learning Python or working on a project, knowing your installed Python version can help you choose compatible tools, packages, and commands. You may also need the version when fixing an error or following a tutorial. The good news is that checking it takes only a few seconds. In this article, you will learn how to check the Python version on Windows, macOS, and Linux. You will also learn several easy methods for checking it on your computer.
What Is a Python Version?
A Python version identifies a specific release of the Python interpreter. It is generally written in the following format:
Python 3.13.5
The numbers represent:
- 3: Major version
- 13: Minor version
- 5: Micro or patch version
The version matters because different Python releases can have different language features, compatibility requirements, and third-party package support.
You can check the Python version from a terminal with a command such as: python –version
On some macOS and Linux systems, you may need: python3 –version


How to Check Python Version on Different Systems?
The command you need depends on your operating system and how you installed Python. Here are the easiest ways to check the installed version:
| System or environment | Command |
| Windows | python –version |
| Windows with Python launcher | py –version |
| macOS | python3 –version |
| Linux | python3 –version |
| Python interpreter | import sys; print(sys.version) |
| Jupyter Notebook | import sys; print(sys.version) |
Pro Tip: Want to learn Python programming? Enroll in Internshala Trainingsā Python course with AI to upgrade your skills and get placement assistance.
How to Check Python Version on Windows?
Windows users can check Python from Command Prompt or PowerShell. The easiest method is to open one of these tools and enter a version command.
i. Using Command Prompt
If you want to know how to check the Python version in Command Prompt, follow these steps:
- Press Windows + R.
- Type cmd and press Enter.
- Run: python –version
The command returns the version associated with the python command.
You can also use the shorter form:
| python -V |
If you use the Windows Python launcher, you may also see the version with:
| py –version |
If you have multiple Python runtimes installed, the Python tools can help you identify the available versions. Current Python documentation also uses āpy listā with the newer Python Installer to list installed runtimes.
ii. Using PowerShell
Open PowerShell and run:
| python –version |
You can also try:
| py –version |
If the command is not recognized, Python may not be in your PATH, or the command may not match the installation you expect.
How to Find Python Version on macOS?
Open Terminal and run:
| python3 –version |
You can also use:
| python3 -V |
If you have multiple Python installations, the command available in your terminal may point to a different interpreter from the one used by a project or development tool.
If python3 is not available, the command may return an error. This usually means Python 3 isn’t installed or the command isn’t available in your current PATH. Using python3 is common on macOS because python and python3 can point to different commands or installations.
How to Know Python Version on Linux?
Open the Terminal and run:
| python3 –version |
You can also check:
| python –version |
On many Linux systems, python3 is the more appropriate command when you specifically want Python 3. If both commands are available, they may point to different Python installations.
How to Check Python Version Using Python Code?
You can check the version from within Python using the sys module.
Run:
| import sysprint(sys.version) |
This returns the Python version along with additional build and interpreter information. If you need the individual version components, use:
| import sys print(sys.version_info.major)print(sys.version_info.minor)print(sys.version_info.micro) |
sys.version_info provides structured information about the interpreter version, including the major, minor, micro, release level, and serial components.
For a simple version string, you can also use:
| import platform print(platform.python_version()) |
This returns a value such as:
| 3.13.5 |
How to Check Python Version in Jupyter Notebook?
Jupyter Notebook can use a different Python interpreter from the one available in your system terminal. So, checking the version inside the notebook helps you identify the Python environment the notebook actually uses.
Create a new cell and run:
| import sysprint(sys.version) |
You can also run:
| : !python –version |
or, depending on your system:
| !python3 –version |
The sys.version method is generally more useful when you want to identify the interpreter running the notebook itself.
How to Check Python Version in VS Code?
VS Code can work with multiple Python interpreters and environments. The selected environment powers Python development features and code execution. To check or change the Python interpreter:
- Open your Python project in VS Code.
- Select the Python version or environment shown in the Status Bar.
- Review the available interpreters.
- Select the environment you want to use.
You can also open the Command Palette and run:
| Python: Select Interpreter |
To verify the version from the VS Code terminal, run the command appropriate for your operating system:
| python –version |
or:
| python3 –version |
If the version shown in VS Code differs from the version shown in your regular terminal, check which interpreter VS Code has selected.
How to Check Python Version Using pip?
pip is used to install and manage Python packages. You can use it to identify the Python interpreter associated with a particular pip command.
Run:
| python -m pip –version |
On macOS or Linux, you may use:
| python3 -m pip –version |
The output includes information about the pip installation and the associated Python version.
Using python -m pip is useful when multiple Python installations exist because it explicitly connects pip to the interpreter invoked by python.
To check the version of a specific package, use:
| python -m pip show requests |
To list installed packages:
| python -m pip list |
How to Check Python Version of a Virtual Environment?
A virtual environment can use a different Python interpreter from the system-wide installation. This means the Python version shown inside a project environment may differ from the version you see when the environment is inactive.
First, activate the environment.
Windows:
| venv\Scripts\activate |
macOS or Linux:
| source venv/bin/activate |
Then run:
| python –version |
On macOS or Linux, you can also use:
| python3 –version |
The result shows the Python interpreter available in the active environment. You can also check whether your current interpreter is running inside a virtual environment:
| import sys print(sys.prefix != sys.base_prefix) |
A result of āTrueā indicates that the interpreter is running in a virtual environment. For project isolation, current Python documentation recommends creating a virtual environment for each project.
How to Check Python Version in a Script?
If you want a script to display the Python version it is using, add:
| import sys print(sys.version) |
For a shorter version number:
| import platform print(platform.python_version()) |
This can be useful when the same script behaves differently across computers or environments.
What to Do If the Python Version Command Is Not Working
If a version command returns an error, first try the alternative command for your operating system.
Windows:
| python –version py –version |
macOS or Linux:
| python3 –version |
If none of these commands work, check whether your system can locate the Python executable.
Windows:
| where python |
macOS or Linux:
| which python3 |
If it returns a path, the system has found an executable for that command. If no path is returned, Python may not be installed or may not be available through your PATH.
If you recently installed Python or changed your PATH settings, opening a new terminal can help it recognize the updated configuration.
Common Issues When Checking Python Version
Before troubleshooting Python version commands, it helps to understand what may be causing the command to fail or return an unexpected result. The following are two common issues you may encounter when checking your Python version, along with simple ways to identify and resolve them.
i. Python Is Not Recognized or Command Not Found
This error usually appears when your system cannot locate the Python executable associated with the command you entered. This may happen if Python isn’t installed, its executable isn’t added to the system PATH, or your installation requires a different command.
Try an alternative command based on your operating system:
Windows: py –version
The Python launcher may work even when the python command is not recognized.
macOS or Linux: python3 –version
Many macOS and Linux systems use python3 to run Python 3. If neither command works, check whether Python is installed on your computer. You should also verify that the Python executable is in your system’s PATH. After installing Python or changing PATH settings, you may need to open a new terminal window and run the command again.
ii. Python and Python3 Show Different Versions
If python –version and python3 –version return different versions, your computer may have multiple Python installations. Each command can point to a different Python interpreter. For example, python might point to one installation while python3 points to another. This can affect which Python version is used when you run a program or install packages.
To identify the location of the Python executable, use the following commands:
Windows: where python
macOS or Linux: which python; which python3
The commands return the paths of the corresponding Python executables. If they show different paths, the two commands are likely using different Python installations. Then check the version of each interpreter and select the one your project needs.


Conclusion
Knowing how to check the Python version helps you confirm your computer is using the right Python release for your projects, packages, and coding tasks. The quickest method is usually a simple command such as python –version, py –version, or python3 –version, depending on your system. You can also check the version inside Python, Jupyter Notebook, VS Code, a script, pip, or a virtual environment. If the command does not work, check your Python installation, PATH, and selected interpreter. Once you know which Python version you are using, it becomes much easier to choose the right tools and solve compatibility problems.
Want to strengthen your Python skills before your next interview? Check out the Python coding interview questions and answers to practice key concepts and prepare with greater confidence.
FAQs
Open your terminal or Command Prompt and run:
python –version
You can also try python3 –version or py –version, depending on your operating system.
Open Command Prompt and enter:
python –version
If it does not work, try:
py –version
These commands display the Python version associated with that command.
On Windows, open Command Prompt or PowerShell and run:
python –version
You can also use:
py –version
Open Terminal and run:
python3 –version
The terminal will display the installed Python 3 version available through that command.
Run this code in a notebook cell:
import sys
print(sys.version)
It will show information about the Python interpreter used by the notebook.
