How to Check Python Version – A Quick Guide
Check Python Version from the Command Line
Python provides a built-in command to check its version.
Step 1: Open the Command Line
- Windows: Press Win + R, typecmd, and press Enter.
- macOS/Linux: Open the Terminal (Ctrl + Alt + Ton Linux).
Step 2: Run the Python Version Command
For Python 3 (recommended)
python3 --version
or
python3 -V
For Python 2 (if installed)
python --version
🎉 Example Output:
Python 3.10.12
💡 Best Practice: Use python3 --version to ensure you’re checking Python 3, as some systems may default to Python 2.
Check Python Version Inside a Script
You can also check the Python version inside a script using the sys module.
Step 1: Create a Python Script (check_version.py)
import sys
print("Python Version:", sys.version)
print("Version Info:", sys.version_info)
Step 2: Run the Script
python check_version.py
Example Output:
Python Version: 3.10.12 (main, Dec 25 2023, 10:05:17) [GCC 9.4.0]
Version Info: sys.version_info(major=3, minor=10, micro=12, releaselevel='final', serial=0)
💡 Best Practice: Use sys.version_info for detailed version checks in scripts.
Check Python Version in VS Code & PyCharm
VS Code
- Open the Terminal (Ctrl + ~).
- Run
python --version
or python3 –version
PyCharm
- Open PyCharm and go to File > Settings > Project: YourProject > Python Interpreter.
- The Python version will be displayed next to the selected interpreter.
💡 Best Practice: In VS Code, use the Python: Select Interpreter command to check and change the Python version.
 
  
 


