4

I have installed python 2.6.6 and python 2.5.5 on the same machines (Ubuntu 10.0.4), since 2.6 is my default version and 2.5 I need for maintaining old stuff. But I have a problem to install modules(MySQLdb and net-snmp) to non-default 2.5v. It seems that only 2.6 is updated when 'sudo apt-get install _module_name_' is called. Is there a way to tell for which version module should be installed? Thanks in advance

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
Milan Lenco
  • 95
  • 1
  • 3
  • 7
  • 1
    You should be using virtualenv instead of global installed. Anyway, you can override the installation directory through --install-dir and specify the site-packages of your desired python version. – CastleDweller May 13 '11 at 11:40

2 Answers2

3

You can use easy_install. To use it for particular version, you just execute it like for example sudo python2.5 easy_install package_name.

vartec
  • 131,205
  • 36
  • 218
  • 244
  • 1
    pip is recommended over easy_install because of how pip plays with virtual env – Jakob Bowyer May 13 '11 at 12:01
  • @Jakob: the situation described is not `vituralenv` and `pip` still ins't drop in replacement for `easy_install`. For example it cannot install from `.egg`. – vartec May 13 '11 at 12:26
  • Thank you.This way I succeeded to install various modules, but I have got stuck with net-snmp-python.This package isn't listed in pypi.python.org, but it is available in repositories (apt-get install net-snmp-python) and also source codes and rpm files can be found (http://www.net-snmp.org/wiki/index.php/Python_Bindings). However using easy_install with source codes failed, since setup.py is not available. According to this: http://www.net-snmp.org/wiki/index.php/Python_Bindings package is also located in some python subdirectory, but I can't find it anywhere within Python2.5.5 source codes. – Milan Lenco May 16 '11 at 14:03
1

You could install Pip for both 2.5 and 2.6 then create an alias in your bashrc like I have which I can do

pip25 install _package_

or

pip26 install _package_

That way you have exact control over where a module installs.

Jakob Bowyer
  • 33,878
  • 8
  • 76
  • 91