Using the Command Line
One of the quickest and easiest ways to check the Python version installed on your system is by using the command line. Here’s how you can do it:
1. Open the command prompt or terminal on your system.
2. Type the following command and press Enter:
python –version
This command will display the Python version installed on your system.
Alternatively, you can also use the following command:
python -V
Both of these commands will give you the same result, which is the Python version.
Using the Python Interpreter
Another way to check the Python version is by using the Python interpreter. Here’s how you can do it:
1. Open the command prompt or terminal on your system.
2. Type the following command and press Enter:
python
This will open the Python interpreter.
3. Once the Python interpreter is open, you can check the Python version by typing the following command and pressing Enter:
import sys
print(sys.version)
This will display the Python version installed on your system.
Using an Integrated Development Environment (IDE)
If you are using an Integrated Development Environment (IDE) for Python development, you can easily check the Python version from within the IDE. Here’s how you can do it in some popular IDEs:
1. PyCharm:
– Open PyCharm.
– Go to «File» > «Settings» (or «Preferences» on macOS).
– In the settings window, navigate to «Project» > «Project Interpreter».
– The Python version will be displayed next to the project interpreter.
2. Visual Studio Code:
– Open Visual Studio Code.
– Open a Python file or create a new one.
– In the bottom-left corner of the editor, click on the Python version.
– The Python version will be displayed in a dropdown menu.
3. Jupyter Notebook:
– Open Jupyter Notebook.
– Create a new notebook or open an existing one.
– In a code cell, type the following command and run the cell:
!python –version
This will display the Python version in the output cell.
Checking Python version in a Python script
If you want to check the Python version within a Python script, you can use the following code:
import sys
print(sys.version)
This code will print the Python version when executed.
Now you know several quick and easy methods to check the Python version installed on your system. Whether you prefer using the command line, the Python interpreter, an IDE, or a Python script, you can easily find out the Python version with just a few simple steps.