Loading multiple versions of the same package at the same time

della matteodellamico at gmail.com
Thu Nov 27 10:22:47 CET 2008


Hi all,

I've got some pickled files representing graphs (using networkx,
http://networkx.lanl.gov if you're interested) that were produced
using version 0.36 of the library.

Now, they have released a new version of the library which is
incompatible with respect to pickled files, so what I'd like to do is
to write a script that loads the two versions of the library at once,
unpickles with the old one, creates a new object with the new version
and re-pickles it with the new version.

So, I installed the two versions of the package using easy_install -m,
but it looks like I can't import the two versions at once:

>>> from pkg_resources import require
>>> require('networkx==0.36')
[networkx 0.36 (/usr/lib/python2.5/site-packages/networkx-0.36-
py2.5.egg)]
>>> import networkx as nx_old
>>> require('networkx==1.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 626,
in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 528,
in resolve
    raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (networkx 0.36 (/usr/lib/python2.5/site-
packages/networkx-0.36-py2.5.egg), Requirement.parse('networkx==1.0'))

Any ideas?
Thanks a lot
matteo



More information about the Python-list mailing list