Introduction
To find out which version of Python is installed on your system, you need to use simple commands that work across different operating systems. This guide explains how to check which python version is installed, covering command‑line methods, interactive checks, and IDE options, so you can quickly verify the interpreter you are using Not complicated — just consistent..
Methods to Check Python Version
Using the Command Line
The most universal way to discover the Python version is through the terminal or command prompt.
-
Open the shell
- On Windows, launch Command Prompt or PowerShell.
- On macOS or Linux, open the Terminal application.
-
Run the
--versionflagpython --versionIf the
pythoncommand points to Python 3, the output will be something likePython 3.11.4. -
Alternative command for systems with both Python 2 and Python 3
python3 --versionThis explicitly invokes the Python 3 interpreter, avoiding confusion when multiple versions coexist.
-
Check the major version only
python -c "import sys; print(sys.version_info.major)"The script prints just the major number (e.g.,
3).
Using Python Interactive Mode
You can also query the version directly from an interactive session That's the part that actually makes a difference..
-
Start the interpreter
python -
Enter the following command
import sys print(sys.version)The output displays the full version string, including build date and compiler information Small thing, real impact. Which is the point..
-
Or obtain a concise version tuple
import sys print(sys.version_info)This returns a tuple such as
(major, minor, micro, releaselevel, serial)Turns out it matters..
Using Integrated Development Environments (IDLE)
If you prefer a graphical approach, most IDEs provide version information in their menus.
-
IDLE (bundled with Python)
Open IDLE → Help → About IDLE. The dialog shows the associated Python version. -
PyCharm, VS Code, Jupyter Notebook
Check the status bar or open the Python interpreter settings; the selected interpreter’s version is displayed Still holds up..
Checking Version via Environment Variables
Sometimes the PYTHON_VERSION environment variable is set manually It's one of those things that adds up..
echo $PYTHON_VERSION # macOS/Linux
echo %PYTHON_VERSION% # Windows
If the variable exists, its value directly answers how to check which python version is installed. Still, this method is less common and only useful when the variable has been configured.
Scientific Explanation
Understanding why these commands work requires a brief look at how Python exposes its version information And that's really what it comes down to..
-
sysmodule: Python’ssysmodule contains aversion_infoattribute, a named tuple that stores the major, minor, micro, release level, and serial numbers. Accessingsys.versionprovides a human‑readable string, whilesys.version_infogives a structured representation that programs can compare Simple as that.. -
Command‑line entry point: When you run
python --version, the interpreter’s entry point reads the__version__attribute from thesysmodule and prints it. This attribute is set at interpreter initialization based on the compiled binary Worth keeping that in mind.. -
Environment variables: The
PYTHON_VERSIONvariable is not part of the standard library, but some deployment scripts set it to simplify version checks in automation pipelines The details matter here..
These mechanisms see to it that any Python installation can reliably report its version, regardless of operating system or shell.
FAQ
Q1: What if python command is not recognized?
A: The shell cannot locate the python executable. Try python3 instead, or add Python to your system’s PATH It's one of those things that adds up..
Q2: I have multiple Python versions installed; which command should I use?
A: Use python3 --version to explicitly target Python 3, or specify the full path (e.g., /usr/bin/python3.9 --version).
Q3: Does the version string include the build date?
A: Yes, sys.version contains the build date and compiler details, while --version shows only the major.minor.micro version.
Q4: Can I check the version from a script without opening a terminal?
A: Absolutely. Include import sys; print(sys.version) in your script and run it with python your_script.py.
Q5: Is there a difference between python and python3 on macOS?
A: On recent macOS installations, python may refer to Python 2.x, while python3 points to the latest Python 3 release. Using python3 avoids accidental invocation of an outdated interpreter It's one of those things that adds up. Turns out it matters..
Conclusion
Knowing how to check which python version is installed is essential for reproducible development, compatibility testing, and troubleshooting. By mastering the command‑line flags (python --version, python3 --version), the sys module’s version_info attribute, and the version display options within popular IDEs, you can confidently verify the interpreter you are using. Apply the methods described above to any operating system, and you’ll always have the information needed to manage your Python environment effectively.
Beyond the command line, the true value of knowing your interpreter version appears once you start juggling multiple environments, IDEs, and dependency managers. The sections below cover those real‑world scenarios so you can confirm your Python version no matter where you happen to be working Surprisingly effective..
Checking the Version Inside a Virtual Environment
A virtual environment isolates its own interpreter and packages, so the version reported inside it may differ from your system‑wide Python. Activate the environment first, then query the version:
# macOS / Linux
source venv/bin/activate
python --version
# Windows
venv\Scripts\activate
python --version
Because activation prepends the environment’s bin (or Scripts) directory to your PATH, the python command now resolves to the isolated interpreter. To confirm which executable you are actually running, use:
import sys
print(sys.executable)
This prints the full path to the active interpreter, which is the most reliable way to verify that your virtual environment—not the global installation—is in use Worth keeping that in mind..
Verifying the Version in Popular IDEs
Most editors surface the selected interpreter in their interface, which is handy when the terminal and the editor disagree.
- VS Code: Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) and choose Python: Select Interpreter. The active version appears in the status bar at the bottom of the window. - PyCharm: deal with to Settings → Project → Python Interpreter.