On Dec 8, 2009, at 3:00 PM, Ning wrote: > Hello > > I am new to python. I have got two version of SQLAlchemy, 0.4.0 and > 5.5. > > Some of my old script built in 0.4.0, and I do not want to change the > script. > > Is that any way I can define in the script to use SQLAlchemy 0.3.11 > for my old script and 5.5 for my new script? > > I think you can use pkgresources to determine which version of > sqlalchemy to be imported. but it is not working, please see my code > below: > > In [23]: from pkg_resources import require > In [24]: require('sqlalchemy == 0.4.0') > Out[24]: [sqlalchemy 0.4.0 (c:\pythonxy\python26\lib\site-packages > \sqlalchemy-0.4.0-py2.6.egg)] > In [25]: import sqlalchemy > In [26]: sqlal > sqlalchemy sqlalchemy-0.4.0-py2.6.egg sqlalchemy-0.5.6-py2.6.egg > In [26]: sqlalchemy.__version__ > Out[26]: '0.4.0' > > That is file, but when i try to load version 5.6. It said got version > conflict > > In [28]: require('sqlalchemy == 0.5.6') > --------------------------------------------------------------------------- > VersionConflict Traceback (most recent call last) > > C:\Pythonxy\Python26\Lib\site-packages\<ipython console> in <module>() > > C:\Pythonxy\Python26\Lib\site-packages\pkg_resources.pyc in require > (self, *requirements) > 624 """ > 625 > --> 626 needed = self.resolve(parse_requirements(requirements)) > 627 > 628 for dist in needed: > C:\Pythonxy\Python26\Lib\site-packages\pkg_resources.pyc in resolve > (self, requirements, env, install > er) > 526 if dist not in req: > 527 # Oops, the "best" so far conflicts with a dependency > --> 528 raise VersionConflict(dist,req) # XXX put more info here > 529 requirements.extend(dist.requires(req.extras)[::-1]) > 530 processed[req] = True > VersionConflict: (sqlalchemy 0.4.0 (c:\pythonxy\python26\lib\site- > packages\sqlalchemy-0.4.0-py2.6.egg), Requirement.parse > ('sqlalchemy==0.5.6'))
To be able to switch between two versions of a package with pkg_resources.require you'll need to install both with the multi-version (-m) argument to easy_install. -- Philip Jenvey -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.