Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top