本文介绍了导入底图时的ImportError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使只是通过pip install basemap安装底图,我也无法导入底图.我已经尝试了python2.7和python3:

I have problems importing basemap, even though I just installed it via pip install basemap. I've tried both with python2.7 and python3:

python3
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'mpl_toolkits'

python2.7
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 37, in <module>
    import _geoslib
ImportError: libgeos_c.so.1: cannot open shared object file: No such file or directory

我正在使用ubuntu操作系统.

I'm on a ubuntu OS.

推荐答案

在ubuntu上对我有用的东西:

What worked for me on ubuntu:

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

这篇关于导入底图时的ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 16:59