Check Python Version
Check Python Version
As you improve your basic Python skills, you’re going to find out (usually the hard way) that Python 2.x and Python 3.x are not as compatible as you expected. That’s why it’s important to establish Python version before starting a new project or deploying it into new environment.
Quickest Way to Check Python Version
Simply use -V option to one of the Python binaries available on your system:
You’ll get the same result if you use –version instead of -V:
Check Python Version By Running python Command
If you start Python in interpreter mode, it should report version information at the very start:
You’ll need to press Ctrl+D (or Cmd+D in macOS) to stop Python.
Check Python Version using sys.version
Sometimes you need to check Python version programmatically, from within your Python script. Then your best bet is to use the sys module:
See Also
- Converting Epoch Time with Python
- Book Review: Practical Programming Python
- AttributeError: module has no attribute in Python
- Setting Alternatives Path for Python in RHEL8
- Simple HTTP Server with Python
- Book review: Introduction to Computer Science with Python
- Book Review: Text Processing with Python
Check Python Version
As you improve your basic Python skills, you’re going to find out (usually the hard way) that Python 2.x and Python 3.x are not as compatible as you expected. That’s why it’s important to establish Python version before starting a new project or deploying it into new environment.
Quickest Way to Check Python Version
Simply use -V option to one of the Python binaries available on your system:
You’ll get the same result if you use –version instead of -V:
Check Python Version By Running python Command
If you start Python in interpreter mode, it should report version information at the very start:
You’ll need to press Ctrl+D (or Cmd+D in macOS) to stop Python.
Check Python Version using sys.version
Sometimes you need to check Python version programmatically, from within your Python script. Then your best bet is to use the sys module:
See Also
- Converting Epoch Time with Python
- Book Review: Practical Programming Python
- AttributeError: module has no attribute in Python
- Setting Alternatives Path for Python in RHEL8
- Simple HTTP Server with Python
- Book review: Introduction to Computer Science with Python
- Book Review: Text Processing with Python