Just another WordPress weblog
8 Sep
I’ve been having problems with an old version of Python on my server. I searched online for a solution but found very little help upgrading Python. There was some suggestions to use virtualenv to have a sandbox Python environment. This was to use different versions of Python at the same time so an upgrade wouldn’t break anything using the older version. I couldn’t get virtualenv to install properly.
In the end I decided to bite the bullet and upgrade version 2.3 to 2.5 using the following instructions.
So far all is good on my server, nothing is broken.
To install Python 2.5 for Linux, you will be downloading and compiling from source. This gives you full control over the installation while preserving the existing Python installation that is present on a Red Hat–based system. The installation assumes that you will be executing all of the following commands as the root user.
The first step is to download and unzip the Python 2.5 source code. In a command-line terminal session, enter the following:
# cd /usr/local/
# wget http://python.org/ftp/python/2.5.1/Python-2.5.1.tgz
# tar -zxvf Python-2.5.1.tgz
# mv Python-2.5.1 Python25
# cd Python25
You have now downloaded and unzipped the source code into /usr/local/Python25. The next step is to compile the source code and make sure the Python interpreter works:
# ./configure --prefix=/usr/local/Python25
# make && make install
# pwd
/usr/local/Python25
# python
Python 2.5.1 (r251:54863, Mar 14 2012, 07:39:18)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on Linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
You are now inside the Python interactive shell, which provides full access to the Python interpreter and any included libraries. A quick test will show that it’s correctly interpreting commands:
>>> print "Hello World!" Hello World! >>> exit() #
Excellent! Everything is working the way you need it to. To ensure that your user environment knows where to find the Python interpreter automatically, you must edit the /root/.bashrc file. I personally use nano to do all of my text editing, but feel free to use whatever editor you are comfortable with. Open the /root/.bashrc file, and at the bottom of the file add the following line:
export PATH=/usr/local/Python25/:$PATH
Yeah you will need to install easy_install be able to install it
sudo python ez_setup.py
Leave a reply