Issues installing Python 2.7

Steven D'Aprano steve+comp.lang.python at
Thu Nov 27 01:53:10 CET 2014

billyfurlong at wrote:

> Hi all,
> Not a python user but I'm trying to upgrade python so I can install pip
> which is required for one of the apps that I'm installing.
> I've tried to install using the below instructions, but when I type python
> I still get the old 2.4.3 version.  Oh Red Hat 5.8 is where I'm installing
> on.

That's good! That means you didn't break the system python, which would be

It's probably possible *in principle* to teach Red Hat Linux to use Python
2.7 as the only version of Python installed, but that will probably break a
lot of critical system scripts like yum. The safest way to deal with this
issue is to 

Your options are:

- upgrade the OS to a more recent version which supports 2.7 out of the box;

- explicitly refer to python2.7 instead of python

- use an alias, I put this in my bashrc:

    alias python='python2.7'

> yum groupinstall "development tools" -y
> yum install readline-devel openssl-devel gmp-devel ncurses-devel
> gdbm-devel \ glib-devel expat-devel libGL-devel tk tix gcc-c++ \
> libX11-devel glibc-devel bzip2 tar tcl-devel tk-devel pkgconfig \
> tix-devel bzip2-devel sqlite-devel autoconf db4-devel libffi-devel \
> valgrind-devel -y
> mkdir tmp
> cd tmp
> wget
> tar xvfz Python-2.7.5.tgz
> cd Python-2.7.5
> ./configure --prefix=/opt/python2.7 --enable-shared
> make
> make altinstall

So far this all looks good to me.

> Add this to the bashrc
> export PATH=$PATH:/opt/python2.7/bin/

I'm not so sure about that, but I don't have time to investigate right now.

> Now the installation worked fine but shouldn't I see that it's using the
> correct version???
> I also did try to run /opt/python2.7/bin/python2.7 and it give me this.
> [root at wmy machine bin]# python2.7
> python2.7: error while loading shared libraries:
> cannot open shared object file: No such file or directory
> Please help the newb.  He's frustrated.

Are you sure that /opt/python2.7/bin/python2.7 even exists? What do "ls -l"
and "file" say about them?


More information about the Python-list mailing list