So the issue is this: I'm attempting to learn how to plot maps with Python, using shapefiles. There are plenty of examples available on the internet, but just about all of them start with something like

from mpl_toolkits.basemap import Basemap

Which, when I attempt to input this into an IPython notebook, the Python console, or Pycharm, returns

ImportError: No module named 'mpl_toolkits.basemap'

To which the next response is, okay, time to sudo apt-get install python-mpltoolkits.basemap. That runs, returning:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-mpltoolkits.basemap is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.

I tried sudo apt-get remove python-mpltoolkits.basemap and then re-installing with apt-get, no joy.

How can I either get the system to recognize that the module exists, or to re-install it in such a way that it's recognizable to the Python interpreter?

  • 1
    I have this same problem. Digging a little depper, after checking the files were installed, I tried: cd /usr/share/pyshared/mpl_toolkits; python -c 'import basemap' and I got an interesting traceback: Traceback (most recent call last): File "<string>", line 1, in <module> File "basemap/__init__.py", line 30, in <module> from mpl_toolkits.basemap import pyproj ImportError: No module named basemap It looks like there is a circular dependency problem.
    – elias
    Dec 26, 2014 at 3:29

4 Answers 4


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.)

  • 3
    pip install basemap doesn't work
    – xApple
    Jan 23, 2016 at 15:20
  • Ah, looks like it doesn't. (It did in the past; strange!) I updated my answer.
    – Luke
    Apr 8, 2016 at 20:21
  • 'conda install basemap' doesn't work as there is a conflict between basemap and Numba. The following command worked for me 'conda install anaconda=custom basemap' May 22, 2018 at 9:10

In my case, the following command worked

sudo apt install python3-mpltoolkits.basemap

first update your conda

$ conda update conda

check your python version

$ conda search "^python$"

creat a virtual environment for your project

$ conda create -n yourenvname python=x.x anaconda

activate your environment

$ source activate yourenvironment

install the basemap package in your environment

$ conda install -n yourenvname basemap

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .