如何在RHEL 7中安装3.5版本之后使用Python 2.7?

时间:2016-03-03 18:07:35

标签: python-2.7 pip yum python-3.5 rhel7

这不是重复,因为建议的文章引用了一般性问题。我的问题是在安装两个版本之后如何修复路径

我在RHEL 7工作,并在Python3.5之上意外安装了Python2.7 ......很长一段时间,它发生了。我需要在我的脚本中使用2.7。我尝试创建一个sym链接,这是有效的,但是yum仍然无法正常工作。另外,如果我用pip安装任何东西,它会将它放入/usr/local/lib/python3.5/site-packages。建议如何解决这个问题?我已经谷歌搜索了几个小时,我把头发拉了出来。先感谢您。

pip版本:

# pip --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)

创建了2.7版本的链接:

# ln -s /usr/local/bin/python2.7 /usr/bin/python

python location:

# which python
/usr/bin/python

检查版本:

# python
Python 2.7.11 (default, Mar  3 2016, 08:44:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>quit()

试图使用yum:

# yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.11 (default, Mar  3 2016, 08:44:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq
卸载/重新安装后,

pip版本没有改变

# pip --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)

0 个答案:

没有答案