1

This is not a duplicate because the suggested article references a general question. My question refers to how do you fix paths after two versions are installed.

Im working in RHEL 7 and accidentally installed Python2.7 on top of Python3.5... long story, it happened. I need to use 2.7 for my scripts. I tried creating a sym link and that works, but yum is still not working. Also, if I install anything with pip, it's putting it into /usr/local/lib/python3.5/site-packages. Suggestions how to fix this? I've been googling for hours and I'm pulling my hair out. Thank you in advance.

pip version:

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

created link to 2.7 version:

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

python location:

# which python
/usr/bin/python

check version:

# 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()

tried to use 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 version has not changed after uninstalling/reinstalling

# pip --version
pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5)
Mike
  • 2,531
  • 6
  • 26
  • 34
  • Possible duplicate of [Official multiple python versions on the same machine?](http://stackoverflow.com/questions/2547554/official-multiple-python-versions-on-the-same-machine) – Tadhg McDonald-Jensen Mar 03 '16 at 18:09
  • if it isn't a duplicate `pip` applies in the same way, use `pip3.5` or `pip2.7` – Tadhg McDonald-Jensen Mar 03 '16 at 18:10
  • I'm confused by what you mean? pip is still pointing to 3.5 after changing the link to 2.7. – Mike Mar 03 '16 at 18:29
  • try running `pip3.5 --version` and `pip2.7 --version` – Tadhg McDonald-Jensen Mar 03 '16 at 18:35
  • 1
    write `ls /usr/local/bin`, there would probably be many versions of pip. use pip2.7 or something. – user_3068807 Mar 03 '16 at 18:35
  • oh my bad, missed the part about the syslink, but yes there should be several versions of pip installed to `/usr/local/bin`... if not then I'm not too sure... – Tadhg McDonald-Jensen Mar 03 '16 at 18:37
  • # pip3.5 --version pip 8.0.2 from /usr/local/lib/python3.5/site-packages (python 3.5) # pip2.7 --version bash: pip2.7: command not found... – Mike Mar 03 '16 at 18:37
  • ... oh... ok if `/usr/local/bin/pip2.7 --version` doesn't work then I have no idea how to help and wish you luck! – Tadhg McDonald-Jensen Mar 03 '16 at 18:39
  • Correct - there are three versions (pip, pip3, and pip3.5) and when I use 'pip' it's installing to 3.5. – Mike Mar 03 '16 at 18:40
  • 2
    Then you have to install pip2. Go to https://pip.pypa.io/en/stable/installing/ and download get-pip.py. Then do `python get-pip.py` ( this is pointing to python2.7 on your system, right?). Now it would change the pips. After installation is done. Go to `usr/local/bin` there would be pip, pip2, pip3.... `pip` would now point to install to python2 packages. for python3 you would use `pip3`. OK? Let us know the result. – user_3068807 Mar 03 '16 at 18:49
  • 1
    ok after forcefully removing pip2.7 from my computer I was able to reinstall it (for verision 2.7) with [`get-pip.py` from here.](http://pip-python3.readthedocs.org/en/latest/installing.html) – Tadhg McDonald-Jensen Mar 03 '16 at 18:49
  • A step closer!! Installing pip2/2.7 via get-pip.py worked! pip2.7 --version pip 8.0.2 from /usr/local/lib/python2.7/site-packages (python 2.7). Any suggestion to get yum working again? Thank you! – Mike Mar 03 '16 at 19:40
  • 1
    @Mike see this http://stackoverflow.com/questions/23589971/yum-not-working. Actually I am not on RH/Fedora. I am on Ubuntu. Hope this helps. Update this thread so that someone else can benefit if runs into the same problem :) – user_3068807 Mar 03 '16 at 21:06
  • Absolutely! I'm still working on the final solution and will post an update of what worked. Thanks! – Mike Mar 04 '16 at 15:05

0 Answers0