如何检查安装在osx和centos上的所有python版本

时间:2022-03-18 06:59:58

I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.

我今天刚开始设置centos服务器,注意到centos上的python默认版本设置为2.6.6。我想用python 2.7代替。我搜索了一下,发现像YUM这样的系统工具使用了2.6.6,所以我不应该篡改它。然后我打开mac上的一个终端,发现我安装了python 2.6.8、2.7.5和3.3.3。对不起,长话短说。简而言之,我只想知道如何查找在centos上安装的所有python版本,这样我就不会意外地安装两次。

3 个解决方案

#1


3  

Use,

使用,

yum list installed
command to find the packages you installed.

#2


22  

The more easy way its by executing the next command:

更简单的方法是执行下一个命令:

ls -ls /usr/bin/python*

Output look like this:

输出如下:

/usr/bin/python           /usr/bin/python2.7        /usr/bin/pythonw
/usr/bin/python-config    /usr/bin/python2.7-config /usr/bin/pythonw2.7

#3


2  

As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in /usr/bin for the Python files (python, python3 etc).

正如评论中提到的,如果CentOS支持哪个python,您可以使用哪个python。另一个可以工作的命令是python。如果没有这些工作,您可以启动Python解释器,它将显示版本,或者您可以查看Python文件的/usr/bin (Python、python3等)。

#1


3  

Use,

使用,

yum list installed
command to find the packages you installed.

#2


22  

The more easy way its by executing the next command:

更简单的方法是执行下一个命令:

ls -ls /usr/bin/python*

Output look like this:

输出如下:

/usr/bin/python           /usr/bin/python2.7        /usr/bin/pythonw
/usr/bin/python-config    /usr/bin/python2.7-config /usr/bin/pythonw2.7

#3


2  

As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in /usr/bin for the Python files (python, python3 etc).

正如评论中提到的,如果CentOS支持哪个python,您可以使用哪个python。另一个可以工作的命令是python。如果没有这些工作,您可以启动Python解释器,它将显示版本,或者您可以查看Python文件的/usr/bin (Python、python3等)。