How to Install Basemap

Hello,

I am having trouble installing Basemap on my machine. I am using Jupyter notebook through Anaconda on a Mac.

Things I’ve tried so far:

Typed in Jupyter: from mpl_toolkits.basemap import basemap
Got error: ModuleNotFoundError: No module named ‘mpl_toolkits.basemap’

In Anaconda: went to Environments, searched for basemap, clicked basemap, clicked apply
Got error: No packages will be modified

UnsatisfiableError: The following specifications were found

to be incompatible with the existing python installation in your environment:

Specifications:

  • basemap -> python[version=’>=3.5,<3.6.0a0|>=3.9,<3.10.0a0’]

  • mpl_sample_data -> python[version=’>=3.9,<3.10.0a0’]

Your python: python=3.8

If python is on the left-most side of the chain, that’s the version you’ve asked for.

When python appears to the right, that indicates that the thing on the left is somehow

not available for the python version you are constrained to. Note that conda will not

change your python version to a different minor version unless you explicitly specify

that.

The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package ncurses conflicts for:

python=3.8 -> readline[version=’>=7.0,<8.0a0’] -> ncurses[version=‘6.0.*|>=6.0,<7.0a0’]

python=3.8 -> ncurses[version=’>=6.1,<7.0a0|>=6.2,<7.0a0’]

Package setuptools conflicts for:

basemap -> matplotlib-base[version=’>=1.0.0,!=3.0.1’] -> setuptools

mpl_sample_data -> matplotlib-base[version=’>=3.3.2,<3.4.0a0’] -> setuptools

python=3.8 -> pip -> setuptools

Package matplotlib-base conflicts for:

basemap-data-hires -> basemap[version=’>1.0.7’] -> matplotlib-base[version=’>=1.0.0|>=1.0.0,!=3.0.1’]

basemap -> matplotlib[version=’>=1.0.0’] -> matplotlib-base[version=‘3.1.2|3.1.2|3.1.2|3.1.3|3.1.3|3.1.3|>=3.2.1,<3.2.2.0a0|>=3.2.2,<3.2.3.0a0|>=3.3.1,<3.3.2.0a0|>=3.3.2,<3.3.3.0a0’,build=‘py37h9aa3819_1|py36h9aa3819_1|py36h9aa3819_0|py37h9aa3819_0|py38h9aa3819_0|py38h9aa3819_1’]

mpl_sample_data -> matplotlib-base[version=‘3.1.2|3.1.2|3.1.2|3.1.3|3.1.3|3.1.3|>=3.2.1,<3.3.0a0|>=3.2.2,<3.3.0a0|>=3.3.1,<3.4.0a0|>=3.3.2,<3.4.0a0’,build=‘py37h9aa3819_1|py36h9aa3819_1|py36h9aa3819_0|py37h9aa3819_0|py38h9aa3819_0|py38h9aa3819_1’]

basemap -> matplotlib-base[version=’>=1.0.0|>=1.0.0,!=3.0.1’]

Package libcxxabi conflicts for:

basemap -> libcxx[version=’>=4.0.1’] -> libcxxabi==4.0.1[build=‘hebd6815_0|hcfea43d_1’]

python=3.8 -> libcxx[version=’>=4.0.1’] -> libcxxabi==4.0.1[build=‘hebd6815_0|hcfea43d_1’]

Package kiwisolver conflicts for:

mpl_sample_data -> matplotlib-base[version=’>=3.3.2,<3.4.0a0’] -> kiwisolver[version=’>=1.0.1’]

basemap -> matplotlib-base[version=’>=1.0.0,!=3.0.1’] -> kiwisolver[version=’>=1.0.1’]

Unsatisfiable Error

Can anyone help? Thank you for your time

Screen Link:

1 Like

Hi @gosaints,

When I had the same issue, I successfully resolved it thanks to this post of @danhthenguyen_nt:

1 Like

Thank you for this.

As you recommended, I ran the following code in Jupyter and it seemed to install properly:

conda install -c conda-forge proj4

Is the next step to search for the epsg file? I did this on my Mac and didn’t find it. I opened a Finder window, typed “epsg”, don’t see anything named “epsg”.

What do you suggest?

Thank you

1 Like

Hi @gosaints,

In my case it was Windows 10 (but I’m not sure if it’s important in this case), and the path was:
C:\Users\LENOVO\anaconda3\pkgs

Have you checked this path: C:\\Utilities\\Python\\Anaconda\\Library\\share
What about the folder ‘pkgs’? Can you search for it?

Yes, the pkgs folder is located in:
Macintosh HD/Users/me/opt/anaconda3

Here is a screen shot of what is in that folder:

There is a ‘share’ folder at:
Macintosh HD/Users/me/opt/anaconda3

Nothing named epsg in there either

Let’s try this code then:

import os
os.environ["PROJ_LIB"] = "Macintosh HD/Users/me/opt/anaconda3"; #fixr
from mpl_toolkits.basemap import Basemap
1 Like

That didn’t work unfortunately. Is it because I am using a Mac? Most of the solutions I find online are for windows

I also found this:

It says that “This is quite likely the last release ever of basemap. Please move development efforts over to Cartopy!”

So I tried to install Cartopy: https://scitools.org.uk/cartopy/docs/v0.15/installing.html#installing

In Jupyter, I get this:

In anaconda, I get this:

In anaconda, I get this when trying to install basemap:

Thank you for your time!

1 Like

Hi @gosaints,

Wait a moment, let’s have a look at this discussion. It seems that the problem described there is exactly your case: no epsg file found, using MacOS, Anaconda. And it seems that it was resolved in that case.

the $ in Jupyter cases a syntax error so I removed them:

I restarted the kernel "kernel then restart and run all’. same thing.

I replaced the ticks with single quotes. same thing

@Elena_Kosourova

So I was googling to find some other mapping package to use instead of Basemap. I came across Folium: https://python-visualization.github.io/folium/quickstart.html

I was able to install it and incorporate it in the NYC public schools/SAT score project which I am finishing up. The maps are very interactive within Jupyter notebook.

Let me know what you think. I’ve uploaded the notebook here.NYC Schools.ipynb (1.1 MB)

Click here to view the jupyter notebook file in a new tab

@gosaints the commands with the $ are bash commands. You enter them in your terminal, not in the notebook!

1 Like

@gosaints,

As for those commands with $ yes, you have to run them in Git Bash terminal, not in Jupyter notebook, @christoph.grabenstei is right. And this symbol $ will be already there as a prompt, you will not have to insert it again.

Anyway, I had a look at your project, and the Folium map looks really great, and the fact that it’s even interactive is an additional advantage!

However, I still cannot understand this problem with installing Basemap on Mac and the fact that the epsg file is not found. I also did some googling and found a few discussions on this argument, but almost all for Windows. And in my case, for Windows, it worked perfectly the solution from the link which I sent you in the first message.

1 Like

Thank you for all your help, I really appreciate it! I’ll will look into this further to try and understand what the issue is.

1 Like