![]() This shouldn’t be often the case, especially once Python 2 has been discontinued for a while. The only reason to learn Python 2 is if your company’s code is written in Python 2 and you need to work with it. It’s syntax and behavior is quite different from Python 2, but it’s generally believed that Python 3 is simpler and easier to understand.Īs Python 2 is no longer supported, you should definitely choose Python 3 if you are writing a new application or just starting to learn Python. Python’s volunteer developers advise that people using Python 2 move to Python 3 as soon as possible. This implies that any bugs or security problems discovered in Python 2 are no longer being addressed by Python developers. However, it is no longer under development and has been discontinued starting from January 1, 2020. Python 2 is an older version that was actively used in software development and IT operations (DevOps). But what’s the difference between the two versions? Now we know how to check the Python version. Pretty simple, right? No wonder Python is so popular. Of course, you can easily obtain the individual components of this tuple using an index (e.g. # sys.version_info(major=3, minor=8, micro=3, releaselevel='final', serial=0) The tuple will contain five components: major, minor, micro, release level, and serial: If necessary, you can also get the version number in the tuple format. To check the Python version using the platform module, use the following code:īoth code snippets output the Python version in the string format. To check the Python version using the sys module, write: The script will be the same for Windows, macOS, and Linux. To check which Python version is running, you can use either the sys or the platform module. This is especially useful when you have multiple Python versions installed on your computer. Sometimes you may want to check the version of Python when you are coding an application (i.e. Starting from Python 3.6, you can also use python -VV (this is two Vs, not a W) to get more detailed information about your Python version: This number is 3 in our case, which means that we have Python 3 installed on our computer. This is indicated by the first number of the full version number. Usually, we are interested in the major version – Python 2 or Python 3. In this case, the full version number is 3.8.3. However, the number next to Python is the version number, which is what we are looking for. You’ll get a result like this:ĭepending on your Python distribution, you may get more information in the result set. Then, for any of the operations systems above, you simply type python -version OR python -V, on the command line and press Enter. Let’s first recall how we can access the command line in different operating systems. You can easily check your Python version on the command line/terminal/shell. Let’s see how you can check the Python version. ![]() So, you should definitely know the version of Python installed on your computer. If the application is written in Python 2, you may not be able to run it using Python 3. The difference between these two versions is quite significant – it’s not just about fixing some bugs and adding a few new features. However, you might have seen that some people use Python 2, while others prefer Python 3. With its simple syntax, high productivity, and amazing open-source libraries, Python can be used for just about anything. Python is one of the most popular programming languages. So, let’s discover how you can check your Python version on the command line and in the script on Windows, macOS, and Linux systems. Although they are two versions of the same language, they have different syntax code written in Python 3 might not work in Python 2. Chances are you have heard about Python 2 and Python 3.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |