Problem importing a module (mpl_toolkits.basemap) in Python

This article describes how to install basemap. And Here is the git repo, and here is a browser downloadable source code.

From the article, in short:
1) Download the source if apt-get install does not work out
2) install the source (super useful if installing to a virtual environment) by:

cd basemap-1.x.x
python setup.py install

Then here is also the doc, with installation guides and how to test if you have installed correctly. (just run from mpl_toolkits.basemap import Basemap in terminal).

It's important to note that if you're having issues with libgeos being detected, the doc suggests that you install the included libgeos source (3.3.3) separately first.


f you're using Anaconda, it has a package for basemap:

conda install basemap

(It looks like pip doesn't have the package any more.)


In my case, the following command worked

sudo apt install python3-mpltoolkits.basemap

Tags:

Python

Apt