On my CentOS 5.8 system (el5 , 64bit), I had python2.4 after OS install and I installed python2.6 now. Now I want to install python modules using yum.

But whenever I install a new python module it "goes" to the python2.4 and is not installed for python2.6.

I tried to replace the python2.4 binary with python2.6 binary. But this broke yum and I had to restore python2.4. So I concluded that it is not a good idea to uninstall python2.4 (that came with base OS) as it might break other system dependencies.

My question is how do I safely install python modules targeting python2.6 without breaking python2.4?

  • You can try PIP or easy_install instead of yum.
    – Alko
    Sep 12, 2013 at 9:05
  • I tried that already. But yum install easy_install2.4 !
    – user17080
    Sep 12, 2013 at 9:07
  • If you installed python26 from EPEL, there are 2.6 modules available there.
    – jordanm
    Sep 12, 2013 at 14:00
  • @jordanm Yes. I did install Python2.6 from EPEL and both Python2.4 & Python2.6 are there in my system currently and they are working fine with no issues. My problem is that when I install any python module (using yum or easy_install) it goes "under" python2.4 (that came with the centOS). Hence the installed python modules are not available to python2.6 which is the python version I want to use.
    – user17080
    Sep 12, 2013 at 14:04

3 Answers 3


I know this is old, but answering in case others come across this. The easiest way to install modules for a specific version of python that is not set as your default would be like this:

pip2.6 install <name of python module>

The above example is assuming 2.6, but of course you could change it to 3.2, 2.7, whatever you are targeting.


  • 1
    A downside to this is that the modules are installed past the systems package managament systems, so e.g. yum isn't able to manage updates and removal. If a module is only needed for a particular user, pip2.6 install --user <module> installs the module using the user scheme to ~/.local/lib/python2.6. Mar 18, 2017 at 8:12

First related question on the right:

Using different versions of Python

To quote vperic directly:

"The recommended way of having multiple Python versions installed is to install each from source - they will happily coexist together. You can then use virtualenv with the appropriate interpreter to install the required dependencies (using pip or easy_install). The trick to easier installation of multiple interpreters from source is to use:

sudo make altinstall instead of the more usual "sudo make install". This will add the version number to the executable (so you'd have python-2.5, python-2.6, python-3.2 etc) thus preventing any conflicts with the system version of Python." and

This sounds like a perfect application for virtualenv, a very popular tool for creating isolated Python environments. This is a sample command to specify the version of Python

$ virtualenv --python=/usr/bin/python2.6 myvirtualenv
  • My problem is not working with multiple python versions. They are working fine. But the default is python2.4 and any installation of python module links to python2.4. But I don't want that. I want the modules to under python2.6.
    – user17080
    Sep 12, 2013 at 9:36

The EPEL provides 2.6 versions of some modules. These modules will always have 26 in the name. Here is an example package name: python26-numpy.

For modules that do not come from RPM, you can run the build system with the correct python binary.

python2.6 setup.py install

This will install the module for your 2.6 installation.

  • This is a way. But I needed to install a lot of python modules for running a python software, lets call it X. I don't know much about X and I don't even have the list of python modules X would need. I plan to resolve as & when an import error pops up. So I can't download all such modules and build rpm and install them. Instead if I can yum to install modules "under" python2.6, I can avoid all these & do yum install ... whenever I hit an error. But if my search on internet(it goes on & on) and SO doesn't help me, will eventually have to do in this horrible way:( +1 for your time anyway :)
    – user17080
    Sep 12, 2013 at 15:56
  • @KingsIndian If you have EPEL enabled, you don't need to download the RPM manually. yum install python26-numpy for example.
    – jordanm
    Sep 12, 2013 at 16:02
  • Oh I see. That's nice. I have already EPEL5 enabled it btw. But I am not sure if all the modules I needed are there in EPEL5. I'll try that out.
    – user17080
    Sep 12, 2013 at 16:56

You must log in to answer this question.