قالب وردپرس درنا توس
Home / Tips and Tricks / How to control Python version – 3 methods

How to control Python version – 3 methods



How to check the Python version

Using the latest version of Python is always recommended if you want to take advantage of the latest security updates, bug fixes and features. But how do you know which version you are on? Read on, and we’ll look at how to check the Python version and install a newer update if needed.

How to check the Python version

When you download Python, you download an interpreter. This means that you effectively “learn” your computer how to understand Python code. All this is to say that Python itself is not a software with a user interface, and therefore there is no automatic update involved.

But it’s still easy to check the Python version. This is because the software itself will be named based on the version. The latest version is Python 3.8.4, and if I search for “Python” on my Windows computer, I see that I have Python 3.6 and 3.5 – so I could do with an update! How to check the Python version!

You can also find the version of Python Shell that you have installed this way. This will usually be the same as your version of Python if you got it from the site.

How to check the Python version in the terminal

You can also check your Python version in the terminal or Windows Command Prompt. Just write:

python --version

OR:

py --version

Either way, you can now see which version you have installed!

Python version in terminal

How to control the Python version programmatically

You can also check which version of Python is running in code. To do this, import the sys module and then use version.

Simply:

import sys
print(sys.version)

The useful thing about this is that it also lets you control which version of Python is running on another user’s machine, which is useful if you want to make sure your app is running on any device without crashing.

Python version Shell

To try this in the shell, just open it and go to File> New file. Add the code via the editor that opens and go to Run> Run module. You will be asked to save your file first. This can of course be run in any editor or IDE.

Where should I go from here?

And there you have it! How to check the Python version on any machine in one of three ways. If you think your version of Python is outdated, check out our guide to updating Python here.

If you do not have Python installed on your machine yet, learn how to install Python here. And when you are ready to start learning, check out our guide to the best online Python courses.

Here you will find a number of fantastic courses that can take you from absolute beginner to qualified professional. The Python Programming Certification Pack 2020 offers particularly good value for money: it offers a really comprehensive guide to the language for just $ 49.99. Hurry up, as it’s usually estimated at $ 2,335!


Source link