I have an Amazon EC2 instance with Red Hat Linux 7.2 installed. It comes with Python 2.7.5 installed system wide.
I've compiled an alternative installation of Python 2.7.8 (which is what I use in another environment that I'm trying to replicate). I will use this to create a virtualenv to launch my Django application.
But invoking python2.7 always takes me to the system-wide python 2.7.5 interpreter.
I followed the instructions at: http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
$ sudo yum groupinstall 'development tools'
$ sudo yum install zlib-dev openssl-devel sqlite-devel bzip2-devel
$ sudo yum install wget
$ sudo wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
$ sudo yum install xz-libs
$ xz -d Python-2.7.8.tar.xz
$ tar -xvf Python-2.7.8.tar
$ cd Python-2.7.8
Edited the file /etc/ld.so.conf to add the line
/usr/local/lib
$sudo /sbin/ldconfig --> make the dynamic linker aware of the change
$sudo ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared
$make
I get the following message, but I'm not sure if this is relevant to my problem.
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _tkinter bsddb185
dbm dl gdbm
imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
$sudo make altinstall
$which python
/usr/bin/python ---> system wide Python 2.7.5
$which python2.7
/usr/local/bin/python2.7 ---> this should point to Python 2.7.8 that was compiled and installed.
But invoking python2.7 points to the system-wide Python 2.7.5 interpreter:
$python2.7
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Why is this happening?
FYI, my PATH does include /usr/local/bin.
$echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin