Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

matplotlib - Python basemap module impossible to import

I have troubles to import the basemap module of mpl_toolkits in python. Here is what I get when I run the test.py script from the module directory:

/usr/lib/python2.7/dist-packages/mpl_toolkits/basemap$ python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from mpl_toolkits.basemap import Basemap, shiftgrid
ImportError: No module named basemap

I can't get it since sys.path gives a list of paths where I am sure the directory "basemap" is, in the "mpl_toolkits" directory. There is no problem to import mpl_toolkits. Here is a thing I tried, to manually add the path, and the result:

>>> import sys
>>> sys.path.append('/usr/lib/python2.7/dist-packages/mpl_toolkits/basemap')
>>> import basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "basemap/__init__.py", line 30, in <module>
from mpl_toolkits.basemap import pyproj
ImportError: No module named basemap

I tried to uninstall an reinstall basemap from source (carefully following these instructions), from apt-get, from conda, but it does not change anything: I can't import basemap.

Thank you for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was in the same situation until a minute ago, installing it through this made the trick:

sudo apt-get install libgeos-3.5.0
sudo apt-get install libgeos-dev
pip install https://github.com/matplotlib/basemap/archive/master.zip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...