1

I am running 64 bit CentOS 7 on an Oracle VirtualBox. The CentOS ISO that I downloaded came with Python 2.7.5 and I am trying to update to 2.7.11, but the normal steps are not working. I downloaded and extracted the tar.gz from the Python website and ran the ./configure and make install steps fine. When I am root then python -V returns Python 2.7.11 as it should, but when I am not the root account then python -V returns Python 2.7.5.

  • 2
    What does type -a python show for root? – thrig Jun 9 '16 at 22:04
  • python is /usr/local/bin/python, python is /usr/bin/python, and python is /bin/python – Jon Jun 9 '16 at 22:34
4

The Python that ships with CentOS 7 comes in an RPM, under normal situations it is best to leave that version installed and install a different/newer version of Python in a separate location, otherwise strange issues can occur when system level applications that use Python are run (not all the time but it might be best since you are new to Linux to avoid those issues).

For your case I would do what you did but when running configure use the command:

./configure --prefix=/usr/local/python2.7.11

You can change the location so you do not have to use the directory listed above but choose something different and follow the same make/make install as you did. Python will then install into a different directory and all you will have to do is add that directory to your path, at that point the new python will run while keeping the system python intact.

  • 1
    I just want to add, replacing the /usr/bin/python on CentOS7 would effectively cripple your system, because you would break the tools used by CentOS to perform software updates. Installing in an alternative location, as this commenter has described, is an appropriate solution. You can also install alternative Python RPMs from reputable 3rd party repos that do not replace the OS python. – jsbillings Jun 11 '16 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.