This post is all about how to check Python version on your computer. But before getting started, let’s know a bit about Python.
这篇文章全部关于如何在您的计算机上检查Python版本。 但是在开始之前,让我们对Python有一点了解。
Python is one of the most popular programming languages. And due to its awesome developer community, you can easily see a lot of different versions getting released quite frequently.
Python是最流行的编程语言之一。 而且由于其强大的开发人员社区,您可以轻松地看到很多不同的版本被频繁发布。
There are two most popular versions of Python as of now, one is Python 2.7.x and the other is Python 3.8.x.
到目前为止,有两个最受欢迎的Python版本,一个是Python 2.7.x ,另一个是Python3.8.x 。
Sometimes you have to work with python library that only supports Python 2.7 and sometimes we have to work with Python 3.x version but we have Python 2.7 installed and we may find our library not supporting the installed version of python.
有时您必须使用仅支持Python 2.7的python库,有时我们必须使用Python 3.x版本,但我们安装了Python 2.7,并且我们可能会发现我们的库不支持已安装的python版本。
In that case, it’s best to check the version of Python installed before downloading the required library.
在这种情况下,最好在下载所需的库之前检查安装的Python版本。
In this tutorial, we will see how to check the python version on Windows, Linux and macOS just with the help of terminal.
在本教程中,我们将看到仅在终端的帮助下如何在Windows,Linux和macOS上检查python版本。
Now, before getting started, you should be able to access your command-line of your OS.
现在,在开始之前,您应该能够访问操作系统的命令行。
Note: This post is all about checking the version of python installed on your computer and in case of windows, most of the time, a windows installation do not have python pre-installed.
注意 :这篇文章全是关于检查计算机上安装的python版本的,对于Windows,大多数情况下,Windows安装中没有预安装python。
如何在Windows中检查Python版本 (How to Check Python Version in Windows)
To see the Python version on a Windows computer, open Powershell and type:
要在Windows计算机上查看Python版本,请打开Powershell并输入:
1
|
python --version
|
1
|
python -- version
|
Now, this is going to give you the version number of python installed on your computer.
现在,这将为您提供安装在计算机上的python的版本号。
1
|
C:\Users\Pratik>python --version
|
1
|
C : \ Users \ Pratik > python -- version
|
Output:
输出:
1
|
Python 3.8.4
|
1
|
Python 3 . 8 . 4
|
如何在Linux中检查Python版本 (How to Check Python Version in Linux)
Similarly, you can check the python version on Linux with the same command. Just open the terminal and type the following command.
同样,您可以使用相同的命令在Linux上检查python版本。 只需打开终端并输入以下命令。
1
|
python --version
|
1
|
python -- version
|
Output:
输出:
1
|
Python 3.6.7
|
1
|
Python 3.6.7
|
如何在Mac OS X中检查Python版本 (How to Check Python Version in Mac OS X)
Open your terminal and type the following command:
打开终端并输入以下命令:
1
|
python --version
|
1
|
python -- version
|
Output:
输出:
1
|
Python 3.6.7
|
1
|
Python 3 . 6 . 7
|
Sometimes you have both the versions of python installed. In that case, to check the version of a particular version of Python then you have to type:
有时您同时安装了两个版本的python。 在这种情况下,要检查特定版本的Python的版本,则必须输入:
1
|
python --version #for python2
|
1
|
python -- version #for python2
|
1
|
python3 --version #for python3
|
1
|
python3 -- version #for python3
|
If you have found this post helpful, please share it with your friends or colleagues who are looking for some python programming.
如果您发现这篇文章有帮助,请与正在寻找python编程的朋友或同事分享。
And if you have started with Python development and stuck in some kind of problem or bug, you can leave your comment here and we will get back to you soon????.
而且,如果您开始使用Python开发并且遇到某种问题或错误,可以在这里留下您的评论,我们会尽快与您联系????。
Thanks for your visit and if you are new here, consider subscribing to our newsletter. See you in my next post. Bye! Take Care!
感谢您的访问,如果您是这里的新手,请考虑订阅我们的时事通讯。 在下一篇文章中见。 再见! 照顾自己!
翻译自: https://www.thecrazyprogrammer.com/2020/07/how-to-check-python-version.html