trying
trying

Reputation: 15

error install basemap on mac

I follow the setup from this link: http://peak5390.wordpress.com/2012/12/08/matplotlib-basemap-tutorial-installing-matplotlib-and-basemap/

However, after I finish all the process. I still encounter error trying to import basemap module. The error message is like the following: from mpl_toolkits.basemap import Basemap ImportError: No module named basemap

Thanks!

Upvotes: 1

Views: 5212

Answers (3)

Carlos Grohmann
Carlos Grohmann

Reputation: 27

This worked for me:

copied the basemap directory from

/Library/Python/2.7/site-packages/mpl_toolkits/

to

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits/

Upvotes: -1

clanmills
clanmills

Reputation: 1

I encountered the same issue on Mac/Yosemite. The following worked for me.

  1. Built and installed the dependencies libraries (freetype and geos)
  2. Built and installed the python code (matplotlib and basemap)

I think there's contention between the mpl_toolkits installed by Apple and those we have just built. So, I moved the Apple supplied kit and used ours in its place.

cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
sudo mv mpl_toolkits/ mpl_toolkits.orig
sudo mv /Library/Python/2.7/site-packages/mpl_toolkits/ .

Test suite runs beautifully:

cd ~/gnu/basemap/basemap-1.0.7/examples
python test.py

Upvotes: 0

Yanik Crépeau
Yanik Crépeau

Reputation: 99

If I do:

import mpl_toolkits mpl_toolkits.\_\_path\_\_ (there are 2 underscore before and after the word path)

I have:

['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits']

Obviously, the basemap sub-package is NOT present under that directory. So, I add one:

mpl_toolkits.__path__.append('/Library/Python/2.7/site-packages/mpl_toolkits')

Now:

mpl_toolkits.__path__ Out[21]: ['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/mpl_toolkits', '/Library/Python/2.7/site-packages/mpl_toolkits']

Then:

In [22]: from mpl_toolkits import basemap

The module baseman started loading but I've got another problem (looking for the geoslib in the wrong path!!) but I think I've made a step in the right direction do solve that issue.

Upvotes: 6

Related Questions