Professional Documents
Culture Documents
How To Check Python Version in Ubuntu
How To Check Python Version in Ubuntu
To check the Python version, Open the command line interface and execute the following
command:
python3 -V
If you automate stuff with Python, sometimes you will need to check the Python version in a
Python script. For this, we use the sys module, which has the version and version_info
objects to check the Python version.
import sys
print(sys.version.split()[0])
import sys
print(sys.version_info.major)
Python 3 is the default version in Ubuntu 20.04 LTS, although Python 2 is still available to
install.
One can install Python 2, by running the apt install python2 command.
SQL Server
MySQL Administration
https://www.configserverfirewall.com/ubuntu-linux/check-python-version-ubuntu/ 1/2
7/17/23, 12:51 PM How to Check Python Version in Ubuntu
Unix
Debian Linux
Ubuntu Firewall
Privacy Policy
https://www.configserverfirewall.com/ubuntu-linux/check-python-version-ubuntu/ 2/2