Reputation: 1224
Is it possible to run different versions of Pandas in different module of the same program?
Upvotes: 1
Views: 1287
Reputation: 2463
If you really need to do this, then, in general, to load packages from specific locations:
import imp
pandas13 = imp.load_module("pandas13",
*imp.find_module("pandas", ["/path/to/pandas13/parent/"]))
pandas14 = imp.load_module("pandas14",
*imp.find_module("pandas", ["/path/to/pandas14/parent/"]))
i.e. pandas 0.13 will be in /path/to/pandas13/parent/pandas/
Then any successive call to import pandas14
will return pandas14
, and import pandas13
will return pandas13
. If this doesn't work, it will be because pandas doesn't use relative namespacing (I think it does), in which case you would need to change all the imports in the package to be relative.
There is no way to do this using absolute in-package imports.
Although, really, I can't imagine why you'd need to do this.
Upvotes: 3