Choose Python version to install egg or install side-by-side versions of site-package

Via fink install

I have installed the following Python version on a Mac OS X machine:

  • python2.3

    ,
  • python2.4

    ,
  • python2.5

    ,
  • python2.6

    ...

It is also python

an alias for python2.6

on my system.

  • I want to install egg for example. easy_install networkx-0.36-py2.5.egg

    where i have to use python 2.5 instead of 2.6. Is this possible without changing the alias python

    ?

  • Can you tell me how and how can I install networkx-0.36-py2.5

    and in parallel networkx-1.0rc1-py2.6

    ?

  • How can I install a site package so that it is available for different Python versions?

+2


source to share


2 answers


Edit: Read Ned Daley's answer before reading this


1.

On my system, I have a different easy_install script for each python version:

  • /usr/bin/easy_install-2.5
  • /usr/bin/easy_install-2.6

The 2.6 content looks like this:

#!/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
import sys
sys.argv[0] = sys.argv[0].replace('-2.6', '')
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c9','console_scripts','easy_install'
__requires__ = 'setuptools==0.6c9'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
)

      

Now, if you don't already have these scripts on your computer, you can create them using the template above. Just change the first line to point to the correct python interpreter. Perhaps something like:

#!/sw/bin/python23

      

And change the third line to match the current script name; meaning if the script is called easy_install-2.3 then it should look like this:



sys.argv[0] = sys.argv[0].replace('-2.3', '')

      

And of course, if you are not using setuptools version 0.6c9, you will have to change that as well.


An alternative is to run easy_install script as an argument to the right python version. Like this:

$ python23 /some/path/easy_install networkx-0.36-py2.5.egg

      

2.

Each python version has a different site-lib, so they are independent from each other. You can install different modules and versions for different python versions.

3.

You can make the PYTHONPATH variable env to the shared directory, or add the shared directory to sys.path in your scripts. But be aware that some modules only work with certain python versions and include C code that needs to be compiled for each python version ...

+2


source


easy_install

is part of the package setuptools

. Fink

has separate packages setuptools

for python 2.5 and python 2.6:

fink install setuptools-py25 setuptools-py26

      

Then you can download and install networkx

in both versions:



/sw/bin/easy_install-2.5 networkx
/sw/bin/easy_install-2.6 networkx

      

If you need a specific version of a package:

/sw/bin/easy_install-2.5 networkx==0.36
/sw/bin/easy_install-2.6 networkx==0.36

      

+3


source







All Articles