Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need to have different versions of pandas to be able to import either 0.13 or 0.14 version. I gone in the path "C:\Python27\Lib\site-packages" and changing the directory name of pandas to pandas_013 but I get the following error.

Has someone a solution to have multi version library with python 2.7?

>>> import pandas_013
No module named pandas.compat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pandas_013\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 37, in init pandas.tslib (pandas\tslib.c:55034)
ImportError: No module named pandas.compat
share|improve this question
    
do you need to use both versions side-by-side in the same code base? –  Paul H Apr 30 '14 at 15:32
    
not really an obligation. I want to choose by importing the good package. –  alexis0587 Apr 30 '14 at 15:43
    
Why not use git to switch back and forth? Or virtualenv. Monkey patching package names in site packages can only lead to a universe of pain. –  Phillip Cloud May 1 '14 at 5:53

1 Answer 1

If you want to use multiple versions, they should be inside your package, probably in a lib package. So then you have mypackage.lib.pandas_013 and mypackage.lib.pandas_014. Next, you need to fix those libraries - remember that they will be filled with imports like the one which errored for you (pandas.compat). So that needs to be changed to mypackage.lib.pandas_013.compat and mypackage.lib.pandas_014.compat, as does every other reference to the original pandas package. An IDE with refactoring or some sed-fu can help here.

share|improve this answer
    
I don't understand the mypackage.lib.pandas_013. Do you want to say that I must have two directory 'C:\Python27\Lib\site-packages\pandas_013' and 'C:\Python27\Lib\site-packages\pandas_014'? Which refactoring do you advice me? Thanks –  alexis0587 Apr 30 '14 at 15:45
    
Oh - did you mean to use pandas from a Python shell, not in your own code? Sorry, you can just use virtualenv then. I thought you wanted both accessible simultaneously (i.e. from the same interpreter). –  Ryan P Apr 30 '14 at 15:48
    
Thx Ryan. I need to be able to do either import pandas_013 or import pandas_014 but the needs is not to do the two in a same script. I will look for virtualenv. –  alexis0587 Apr 30 '14 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.