fixyourserver.com

A lot of stuff and things…

Update Python on cPanel CentOS Servers

Here it is, going to version 2.6.2

Download and install python 2.6.2

cd /usr/local/src/
wget  http://python.org/ftp/python/2.6.2/Python-2.6.2.tgz
tar -xzvf Python-2.6.2.tgz 
cd Python-2.6.2
./configure -prefix=/usr/local/python.2.6.2/
make
make install

2) Configure cpanel for latest Python as follows in cpanel.config

python=/usr/local/python.2.6.2/bin/python2.6

Done! You may want to create a symlink to the bin and move the old school one out.

Next Post

Previous Post

4 Comments

  1. Scott Elkin May 23, 2011

    I am a linux newbie (hence why I am looking up this information)…but how do you “create a symlink to the bin and move the old school one out?”

  2. Admin April 19, 2012 — Post Author

    Hi Scott,
    Apologies on the late response. I’ve gone through some restructuring/domain name changes lately. The proper way to do this is to run “ln -s /usr/local/python.2.6.2/bin/python /usr/bin/python2.6” I recommend adding the 2.6 to the end in order to differentiate installed versions and so as to not corrupt yum since it is heavily reliant on python.

    If you’d like to see any further write ups, let me know! I do this all day anyways, may as well write it down somewhere. 😉

  3. aurelien April 3, 2013

    Hello, I use your tutorial but it still shows the old version of python.
    I installed version 2.7.3 in centos 5.8
    If python -V it displays 2.4.3 🙁
    Best regards

  4. Rob April 3, 2013 — Post Author

    I apologize for the confusion. There’s something that you should know about attempting to update the system’s python. When doing this, it will break some of the essential system components such as yum that are dependent on the version that ships with the operating system. There is a way to work around this though.

    When installing with prefix=/usr/local/python.2.6.2/ the binaries should be in /usr/local/python2.6.2/bin/python (you may have used a different prefix, or if you copy and pasted this, the python version you’re looking for will be in this directory) This ensures that your system’s software that has dependencies on the python version that ships with the OS are not affected by your new installations and only software that you specify to use it will use it. So if you run the following:
    /usr/local/python2.6.2/bin/python -V
    This should result in the proper version. It’s difficult to say without seeing the system in person, but all of your module installations should be based around this path as well.
    So if python is in this directory, the way you would tell your script to work with this would be to add the following shebang line to the head of the python files:
    #!/usr/local/python2.6.2/bin/python

    If you run into any further problems, please feel free to respond and I’ll be happy to help!

Leave a Reply

© 2017 fixyourserver.com

Theme by Anders Norén