We are given linux systems which has Python 2.7.5 installed. And our application requires Python version greater than 2.7.9. When we try to upgrade or install the Python to the latest version, it fails as the default installations requires an entry to be made on the read only file system /usr/local/bin/. Even with root access we cannot modify the /usr/local/bin directory.
So how do we upgrade or install a new version of Python? Below are the steps:
- Download the version of Python which we are interested
- untar the binary to a directory.
- cd <go to the directory where it has been untared>
- run the configure command: ./configure –prefix=/myworks/softwares/pythonV2.7.13 –enable-shared –with-ensurepip=yes && make
- run make command: make altinstall. This command will install the python to the directory specified in prefix path.
- go to the .bash_profile and add the statement: export LD_LIBRARY_PATH=/myworks/softwares/pythonV2.7.13/lib:$LD_LIBRARY_PATH
- Reload the .bash_profile. Its done
Hope it helps