Say, for example that FooPackage-1.1 and FooPackage-1.2 are both installed in dist-packages as eggs. How do I import the one I need?
You can use pkg_resources
to specify your requirements at import time:
import pkg_resources
pkg_resources.require('FooPackage==1.2')
import FooPackage
For example:
% easy_install simplejson==2.1.3
% easy_install simplejson==2.1.2
pkg_resources.require('simplejson==2.1.2')
import simplejson
assert simplejson.__version__ == '2.1.2'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With