Trouble in installing Basemap in matplotlib

…衆ロ難τιáo~ 提交于 2019-12-08 08:35:06

问题


I am trying to install Basemap, and beforehand I already have the prerequisite versions of Matplotlib, Python and Numpy working on my Mac. To install Basemap I am following the instructions in this website http://matplotlib.org/basemap/users/installing.html

I seemed to progress quite well with the steps, until the very end which is "Check your installation by running from mpl_toolkits.basemap import Basemap at the python prompt." I got "ImportError: cannot import name pyproj" from a line that reads "---> 30 from mpl_toolkits.basemap import pyproj".

Does anyone have any idea? Many thanks!


回答1:


The compiled module could be accessible by python. To achieve that you should put the module into python path or you need to add the location of the module to PYTHONPATH environment variable.

To see the python installations paths you can write these lines to python shell:

import sys

for path in sys.path:
    print(path)

The code will show the paths python is looking for modules.

After you compile the c library, you need to go to upper folder and run python setup.py install as it's said in the installation page. This will put python modules into one of your python paths.




回答2:


I had the same problem installing basemap-1.0.7. I found that the file /usr/lib64/python2.6/site-packages/mpl_toolkits/basemap/init.py had a reference to axes-grid1, but python lists only module axes_grid. So I changed grid1 to grid and now basemap imports without error.




回答3:


Had the same issue on OSX, found after much faffing that Basemap worked fine with a non-native version of python (for me 2.7.12 with everything under /opt/local/Library/Frameworks...) but not with the native version (for me 2.7.10 with most stuff under /System/Library/Frameworks... and Basemap under /Library/...). I did note also that under the native version there was already some mpl_tooklit content and without the permission to add Basemap there you end up with mpl_toolkit contents in multiple places. I wasn't sure if this was the problem specifically but as I said having it all under opt using non-native python was what solved this for me.



来源:https://stackoverflow.com/questions/21375965/trouble-in-installing-basemap-in-matplotlib

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