Version errors for numpy when importing matplotlib

半城伤御伤魂 提交于 2019-12-04 05:07:58

Forcing reinstall works in this case, as it will often do in similar cases:

sudo pip install -U --force-reinstall scipy

I had this same error as well. I was able fix it by installing numpy through my python IDE. I am using PyCharm. When Pycharm opens there is an option to configure things and from there you can select python interpreters. On the righthand side a panel should appear with two options; paths and packages. select packages, then select install, and a list of available packages will pop up. Select numpy from the list and click install from this window. this fixed my error.

In case

sudo pip install -U --force-reinstall scipy

doesn't work (even if you include a specific version), you may want to make sure you've got the right version of numpy installed with the Python you're using. I had the same "numpy.core.multiarray failed to import" issue, but it was because I had 1.6 installed for the version of Python I was using, even though I kept installing 1.8 and assumed it was installing in the right directory.

I found the bad numpy version by using the following command in my Mac terminal:

python -c "import numpy;print numpy.version;print numpy.file";

This command gave me the version and location of numpy that I was using (turned out it was 1.6.2). I went to this location and manually replaced it with the numpy folder for 1.8 (the pip command had installed this elsewhere), which resolved my "numpy.core.multiarray failed to import" issue. Hopefully someone finds this useful!

sudo pip install -U --force-reinstall scipy

works for me, but when you restart on a mac, you have to uncheck the "reopen windows" to make that work

not just restarting :)

Marco

I had the same problem and the cause seems to be the older versions of numpy (as well as scipy,matplotlib in other cases) shipped with Mac OS X mavericks. The following link contains the solution.

https://stackoverflow.com/a/28518106

One need manually delete the older modules located in (in my case) /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/

Then upgrade the modules. The new modules are located in /Library/Python/2.7/site-packages/

One can make sure the import is done by checking

import numpy

print numpy.__file__ or

print numpy.__version__

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!