How To Check Python Version?

Python has become one of the most versatile and widely adopted programming languages, powering applications in data science, machine learning, web development, automation, and beyond. With new versions released regularly, knowing which Python version you’re working with is essential. Whether you're installing a new library, troubleshooting compatibility issues, or preparing a deployment, verifying your Python version is a vital step.
This comprehensive guide covers multiple methods to check your Python version across Windows, macOS, and Linux. It also shows you how to check it programmatically, making it ideal for developers, beginners, and IT professionals alike. By the end, you’ll know exactly how to confirm your Python installation, understand version-specific requirements, and confidently manage your development environment.
Note: Use python3 explicitly on macOS/Linux to avoid running outdated versions (often Python 2.x).
Why Checking Python Version Matters ?

Library and framework compatibility: Popular libraries like TensorFlow, Django, and NumPy often support specific Python versions. Installing incompatible versions can lead to errors.
Security and updates: Older versions may no longer receive security patches. Staying updated helps protect your system and applications.
Troubleshooting errors: Many runtime issues stem from mismatches between Python versions and libraries.
Environment consistency: Development teams often standardize environments across projects. Checking Python versions helps maintain uniformity in collaborative work.
Real-world scenario: Suppose you're joining a project that uses Python 3.11 features like pattern matching. If your system only has Python 3.8 installed, your code may fail to run. Quickly checking the version saves time and avoids confusion.
Checking Python Version on Windows
1. Using Command Prompt
Press Win + R, type cmd, and press Enter.
In the command line, enter: python --version or python -V
This will output something like: Python 3.12.1
If you get an error like "Python is not recognized as an internal or external command," it means Python is not added to your system PATH during installation. You can fix this by reinstalling Python and checking the "Add Python to PATH" option.
2. Using Windows PowerShelSearch for PowerShell in the Start menu and open it.
Run the same commands: python --version or python -V.
Open Command Prompt or PowerShell.
Launch the interactive shell by typing: python
Once inside, run:
import sys
print(sys.version)
This prints detailed version information, including the build date and compiler details.
Checking Python Version on macOS
macOS typically includes Python 2.x for system tasks. To use Python 3, you often need to install it separately. Here’s how to check the version:
Using TerminalOpen Terminal from the Applications > Utilities folder.
Run the following command: python3 --version or python3 -V
Output will look like: Python 3.11.6
Note: On macOS, python may point to Python 2.x, while python3 points to Python 3.x. Always use python3 for modern development.
Using the Python ShellOpen Terminal.
Type: python3
Inside the shell, run:
import sys
print(sys.version)
If you installed Python using Homebrew:
Run:
brew list python@3
python3 --version
This confirms the installed version and whether it’s appropriately linked.
Checking Python Version on Linux
Most Linux distributions come with Python pre-installed, but you may want to confirm which version is active.
Using TerminalOpen your terminal and type: python3 --version or python3 -V
This will output something like:Python 3.10.12. On older systems, python may point to Python 2.7. Always verify by using python3.
Using the Interactive Shell
Enter the shell by typing: python3.
import sys
print(sys.version)
Debian/Ubuntu: sudo apt list --installed | grep python3
Fedora/Red Hat: sudo dnf list installed | grep python3
Arch Linux: pacman -Q | grep python
Check the path of the Python binary: which python3.
Then run: /path/to/python3 --version
Checking Python Version Programmatically
In many cases, especially in automated scripts, checking the Python version from within your code is useful.
Use the sys module:
import sys
print("Python version:", sys.version)
print("Version info:", sys.version_info)
Write conditional code based on the version.
Automate deployments that require specific Python versions.
Create environment logs for debugging.
You can even add a version check at the beginning of your scripts:
import sys
if sys.version_info < (3, 9):
raise Exception("This script requires at least Python 3.9")
Python Version Management with Bhrighu Academy
Learning to manage Python versions is part of becoming a proficient developer. At Bhrighu Academy, we go beyond teaching Python syntax. Our beginner-friendly Python courses introduce you to best practices for version management, virtual environments, and environment setup.
Through our guided training programs, you’ll:Learn how to install and manage multiple Python versions.
Understand when to use python, python3, and version-specific environments.
Get hands-on experience using tools like venv and pyenv.
Avoid common pitfalls that beginners face when dealing with version conflicts.
We help students build a strong foundation in coding and configuring robust and scalable development environments.
Conclusion
Knowing how to check your Python version is essential for every developer. Whether you're using Windows, macOS, or Linux, the command line, or Python scripts, the methods outlined in this guide ensure that you're always in control of your environment.
By understanding your Python version, you’ll avoid compatibility issues, streamline development, and maintain secure systems. As you continue your programming journey, these foundational practices will save time and help you work more efficiently.
Ready to master Python and learn how to manage environments like a pro? Join Bhrighu Academy’s expert-led Python courses. Our structured, hands-on approach ensures you gain coding skills and the operational know-how to succeed in real-world projects.
Explore Bhrighu Academy today and take the first step toward becoming a confident Python developer.
Frequently Asked Questions
How to find Python with cmd?
To find Python via Command Prompt, open cmd and type python --version or python. If Python is installed and added to the system PATH, this will return the version or launch the interpreter. If not found, ensure Python is installed and PATH is correctly set during installation.
How to check if Python 3.12 is installed?
Open Command Prompt or Terminal and type python3.12 --version. If Python 3.12 is installed, it will return the version number. Alternatively, use py -3.12 in Windows or check with where python3.12 or which python3.12 to locate the installation path and confirm its presence.
How do I know if I have Python 2 or 3?
Type python --version and python3 --version in your terminal or command prompt. Python 2 typically appears as Python 2.x.x, while Python 3 shows Python 3.x.x. On many systems, python defaults to Python 2, and python3 explicitly calls Python 3.
What is the latest Python version?
As of May 2025, the latest stable Python release is Python 3.12.3. To verify the most recent version, visit the official Python.org website. Always download from the official source to ensure security and access to the newest features and bug fixes.