Popular
Data Science
Technology
Finance
Management
Future Tech
Python is a high-level and dynamic language. It sees frequent new releases every year — each time bringing improved functionality and bug fixes— from its development organisation. Web development, data analysis, machine learning, and scripting are just a few examples of what tasks can be achieved using the Python programming language. However, it should be noted that Python, like any other software program, exists in multiple versions. Regulatory oversight on which version your machine runs is thus a task to ensure conformity with the scripts to be run.
In this article, we will go through in detail on how to check the Python version in Linux, Windows, and macOS. We will use different methods to check for the installed Python version in our system along with the major and key versions Python has released till now.
Python stands as a high-level programming language — not to mention a powerful one — that offers effective high-level data structures and an uncomplicated introduction to the object-oriented paradigm. While Python is recognized for its easy-to-understand syntax, it also excels in the world of object-oriented programming effectiveness and dynamic typing. Python makes use of an interpreter, alongside a wide range of standard libraries, which allows for program development. As such, it positions itself as an ideal scripting language— finding applicability in rapid application development across different domains. Since its first release in 2001 i.e., Python 2.0.1 version, it has come up to its latest Python 3.12.4 version with various of the latest features in its effectiveness, security, and bug fixes.
Python versions are the new releases that are released by the organisation with new features, bug fixes, security updates, and many more things. Since its introduction, Python has seen multiple major revisions, the most notable being Python 2 and Python 3. While Python 2 became inactive on January 1, 2020, Python 3 is the most recent major version and is still actively maintained. Knowing the version of Python you are using is crucial because every version of the language adds new enhancements, features, and occasionally unsettling changes.
Linux is a popular operating system to run Python programs and develop applications using Python. Linux offers the best command line and shell scripting features for Python. To check the Python version in Linux, we have different methods to do it including:
Linux provides an interactive shell for the users to use its various functionalities. Checking the Python version using this interactive shell is very easy. To check the Python version, follow the below steps:
1. Open your terminal and run the following command:
For Python 2.x:
python
For Python 3.x:
python3
2. Once you’re in an interactive shell, check for the version of Python by running the below commands:
import sys
print(sys.version)
Using the Linux command line or terminal, you can also check the Python version. To check the Python version, follow the below steps:
For Python 2.x:
python –version
Or
python -V
For Python 3.x:
python3 –version
Or
python3 -V
Python is popular for its scripting features. To check for the Python version, we can write a script also. See the below steps:
1. Create a new file with any name like check_ver.py and add the following code to it:
2. Run the script:
We can also create Python virtual environments to check for the versions. To do this, create a virtual environment by activating it, and you may use the version command to see the Python version there. Let’s see how:
1. Create a Virtual Environment
For Python 3.x:
python3 -m venv myenv
2. Activate the Virtual Environment
For bash or zsh:
source myenv/bin/activate
For the fish shell:
source myenv/bin/activate.fish
3. Check the Python version by running the command
python –version
Or
python -V
Windows OS is also used to run Python programs and develop the latest applications. Tasks like Machine learning, artificial intelligence, and data analysis are performed in Windows using Python. Therefore, it is necessary to be updated with the latest version of Python. To check the Python version in Windows, we have different methods to do it including:
Windows provides the PowerShell same as the shell in Linux, for the users to use its various system administration functionalities. Checking the Python version using this PowerShell is easy. To check the Python version, follow the below steps:
1. Open the PowerShell (use Win + X) and select Windows PowerShell or Windows PowerShell (Admin)
2. Run the following command:
For Python 2.x:
python –version
For Python 3.x:
python3 –version
Using the Windows terminal or command line, you can also check the Python version. To check the Python version, follow the below steps:
For Python 2.x:
python –version
Or
python -V
For Python 3.x:
python3 –version
Or
python3 -V
Python is popular for its scripting features. To check for the Python version, we can write a script in Windows also. See the below steps:
1. Create a new file with any name like check_ver.py and add the following code to it:
2. Run the script:
We can also create Python virtual environments in Windows to check for the versions. To do this, create a virtual environment by activating it and using the version command to see the Python version there. Let’s see how:
1. Create a Virtual Environment
For Python 3.x:
python -m venv myenv
2. Activate the Virtual Environment
For cmd:
myenvScriptsactivate
For powershell:
myenvScriptsActivate.ps1
3. Check the Python version by running the command
python –version
Or
python -V
MacOS is known for its performance in various development tasks. To check the Python version in Windows, we have different methods to do it including:
Using the macOS terminal, you can also check the Python version. To check the Python version, follow the below steps:
Python is popular for its scripting features. To check for the Python version, we can also write a script in Mac. See the below steps:
1. Create a new file with any name like check_ver.py and add the following code to it:
2. Run the script:
We can also create Python virtual environments in Mac to check for the versions installed. To do this, create a virtual environment by activating it and using the version command to see the Python version there. Let’s see how:
1. Create a Virtual Environment
For Python 3.x:
python -m venv myenv
2. Activate the Virtual Environment
source myenv/bin/activate
3. Check the Python version by running the command
python –version
To get updated with the latest features, security updates, etc., it becomes important to check the Python version of your system. Having checked the Python version installed on your system can ensure that your application is free from the previous bug fixes, security fixes, etc. Here are some of the factors that significantly imply why it’s important to check the Python version:
Python’s first version was launched in 1991, and since then, it has undergone various changes, including some minor and others major, with a slew of new features or security enhancements and, at times, even adjustments that would change the game. Developers need to have a good grasp of the different versions of Python if they are to ensure compatibility while also staying alongside the latest developments in the language. Here’s a preview of some significant changes made to Python’s version:
Below are the key Python versions starting from its pre-release and first launch till the current versions:
Python Versions | Release Date |
Python 1.0 | January 1994 |
Python 1.5 | December 31, 1997 |
Python 1.6 | September 5, 2000 |
Python 2.0 | October 16, 2000 |
Python 2.1 | April 17, 2001 |
Python 2.2 | December 21, 2001 |
Python 2.3 | July 29, 2003 |
Python 2.4 | November 30, 2004 |
Python 2.5 | September 19, 2006 |
Python 2.6 | October 1, 2008 |
Python 2.7 | July 3, 2010 |
Python 3.0 | December 3, 2008 |
Python 3.1 | June 27, 2009 |
Python 3.2 | February 20, 2011 |
Python 3.3 | September 29, 2012 |
Python 3.4 | March 16, 2014 |
Python 3.5 | September 13, 2015 |
Python 3.6 | December 23, 2016 |
Python 3.7 | June 27, 2018 |
Python 3.8 | October 14, 2019 |
Python 3.9 | October 5, 2020 |
Python 3.10 | October 4, 2021 |
Python 3.11 | October 24, 2022 |
Python 3.12 | October 02, 2023 |
Python 3.13 | October 10, 2024 (planned) |
Upgrading to the latest version in Python ensures that all new features and bug fixes are being supported in your project. To update the Python version, some steps need to be performed in different operating systems. We will see all the steps for updating the Python version to the latest version in Linux, Windows, and macOS:
Steps to update the Python version to the latest version in Linux:
1. Using Python package manager
For (Debian OS)
Open terminal: Start your terminal and run the following command.
Update the package:
sudo apt update
sudo apt install python3 –reinstall
For (Fedora OS)
Open terminal: Start your terminal and run the following command.
Update the package:
sudo dnf install python3 –reinstall
2. Manual Download
The simplest way to upgrade is to download the latest version from Python’s official website.
Extract the file:
tar -xvzf Python-3.8.0.tgz # Replace with your desired version
Navigate to the extracted directory:
cd Python-3.8.0
Build and install:
./configure
make
sudo make install
3. Using deadsnakes
If you’re using Ubuntu, there’s an additional PPA, known as deadsnakes, that can be used to update to Python’s latest version. Here’s how you can update:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8 # Replace with your desired version
Steps to update the Python version to the latest version in Windows:
Steps to update the Python version to the latest version in macOS:
Method 1: Using Manual Download Installer
Method 2: Using Homebrew
brew update
brew install python
There are situations where you need to downgrade your Python version to a specific version that is compatible with the application or project you’re working on. Here are the steps for downgrading your Python version in Linux, Windows, and macOS:
Steps to downgrade the Python version to the specific version in Linux:
Method 1: Using deadsnakes
1. Open your terminal and run the command:
2. Wait for the installation to complete
Method 2: Using pyenv
1. Download and install the Python’ package “pyenv”. Run the following command:curl https://pyenv.run | bash
2. Now, add “pyenv” to your shell configuration file:
3. Downgrade to specific Python version:
pyenv install 3.5.4 # Replace with your desired version
pyenv global 3.5.4
Steps to downgrade the Python version to the specific version in Windows:
choco install python –version=3.7.9 # Replace with the desired version
Steps to downgrade the Python version to the specific version in macOS:
1. Uninstall the current version
Use the homebrew, and run the command:brew uninstall python
2. Install the specific version
Download the specific version from Python’s official website.
3. Run the installer and install the specific version.
4. Use pyenv
Run the following command to install pyenv:
brew install pyenv
5. Now, add “pyenv” to your shell configuration file:
6. Downgrade to specific Python version:
pyenv install 3.5.3 # Replace with your desired version
pyenv global 3.5.3
For developers, ensuring the Python version is up to date is crucial. This is because it equips them with the most recent features, bug fixes, and security updates, which in turn facilitate the development of applications and programs. We have discussed in detail the different methods to verify the Python version on Windows, Linux, and macOS in this article; take note so you can identify and take charge of your Python environment accurately. Knowing your Python version- whether you work through the terminal, scripts, or virtual environments— plays a major role in guaranteeing compatibility as well as streamlining your development process.
The DevOps Playbook
Simplify deployment with Docker containers.
Streamline development with modern practices.
Enhance efficiency with automated workflows.
Popular
Data Science
Technology
Finance
Management
Future Tech
Accelerator Program in Business Analytics & Data Science
Integrated Program in Data Science, AI and ML
Certificate Program in Full Stack Development with Specialization for Web and Mobile
Certificate Program in DevOps and Cloud Engineering
Certificate Program in Application Development
Certificate Program in Cybersecurity Essentials & Risk Assessment
Integrated Program in Finance and Financial Technologies
Certificate Program in Financial Analysis, Valuation and Risk Management
© 2024 Hero Vired. All rights reserved