Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import pandas #7517

Closed
phani-vadrevu opened this issue Jun 19, 2014 · 12 comments
Closed

Unable to import pandas #7517

phani-vadrevu opened this issue Jun 19, 2014 · 12 comments
Labels
Build Library building on various platforms

Comments

@phani-vadrevu
Copy link

I've installed pandas using pip. I got the following versions of pip and numpy:

pvadrevu@MacPro~$ sudo pip freeze|grep pandas
pandas==0.14.0
pvadrevu@MacPro~$ sudo pip freeze|grep numpy
numpy==1.8.1

I am using this on OSX 10.9.2. I get the following error when trying to import pandas

numpy.dtype has the wrong size, try recompiling
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:22331)
ValueError: numpy.dtype has the wrong size, try recompiling
@shoyer
Copy link
Member

shoyer commented Jun 19, 2014

pip will sometimes install/upgrade dependencies in an arbitrary order. This error message indicates that pandas was built against an older version of numpy. If you reinstall pandas it should go away.

@phani-vadrevu
Copy link
Author

I did try uninstalling pandas and reinstalling it. But I get the same error again.

Compiling pandas from source seems to work though. Only pip installation produces the above error for me.

@phani-vadrevu
Copy link
Author

I posted an answer on what works for me in the first question (installing from source). But for some reason, I cannot get to install it using pip.

@Henry2012
Copy link

@phani-vadrevu Following your instructions, I can import pandas finally.

  1. updated numpy to 1.9.0 using "sudo easy_install -U numpy" (while "sudo pip install -U numpy" did nothing but keep the old version)
  2. checked whether numpy was updated to the latest version
  3. updated pandas to the latest version using easy_install
  4. checked whether importing pandas works.
  5. done.

@ghost
Copy link

ghost commented Sep 12, 2014

+1 works for me! Thank you!

@nspies
Copy link
Contributor

nspies commented Sep 14, 2014

I can confirm that pip is installing numpy 1.6.2 and that using easy_install to upgrade bumpy to 1.9.0 makes the pip pandas installation work properly. I'm not sure why pip isn't installing the most recent version of numpy, but the easy_install workaround works, as does installing pandas from source (the pip install doesn't actually seem to work against numpy 1.6.2).

@mahiuchun
Copy link

Same error with both numpy and pandas being latest versions:

$ pip freeze | egrep 'numpy|pandas'
numpy==1.9.0
pandas==0.14.1

@cpcloud
Copy link
Member

cpcloud commented Oct 5, 2014

@Henry2012 @nspies @maxiaojun @phani-vadrevu

couple of points

that said, i'm happy to help someone set up an environment using any of the above tools, but trying to track down the reason as to how/why/when you clobbered something is an exercise in futility.

FWIW, I'm also running 3 versions of Windows, Arch Linux, and Mac OS X 10.9.5 and I've yet to run into this problem using any of the above mentioned tools. Also, if you ever need to work on a machine that's not your own and you don't have sudo privileges then you won't be able to install anything. Avoid sudo pip install <package> at all costs, especially since there are easier, more robust ways of handling packaging.

@HonzaSaibic
Copy link

Right now i had the same issue. If you are using Virtual Env and you install pandas, you have to deactivate the env. After you activate it again it should work. 🎉

@AaryamanCodes
Copy link

AaryamanCodes commented Mar 20, 2020

I am on windows 10 python 3.8 and this error message occurs:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import pandas
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas_init_.py", line 55, in
from pandas.core.api import (
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\api.py", line 29, in
from pandas.core.groupby import Grouper, NamedAgg
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\groupby_init_.py", line 1, in
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\groupby\generic.py", line 60, in
from pandas.core.frame import DataFrame
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\frame.py", line 124, in
from pandas.core.series import Series
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\series.py", line 4572, in
Series._add_series_or_dataframe_operations()
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\generic.py", line 10349, in add_series_or_dataframe_operations
from pandas.core.window import EWM, Expanding, Rolling, Window
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window_init
.py", line 1, in
from pandas.core.window.ewm import EWM # noqa:F401
File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\ewm.py", line 5, in
import pandas._libs.window.aggregations as window_aggregations
ImportError: DLL load failed while importing aggregations: The specified module could not be found.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Mar 20, 2020

@AaryamanCodes see #32857, which is reporting a similar error. Can you share information on how you installed pandas over there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms
Projects
None yet
Development

No branches or pull requests