Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError when importing Basemap

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

I'm on a ubuntu OS.

like image 242
bjornasm Avatar asked Dec 09 '22 04:12

bjornasm


1 Answers

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
like image 195
Padraic Cunningham Avatar answered Dec 10 '22 17:12

Padraic Cunningham