2

I tried to install basemap on google colab and run these commands:

!apt-get install libgeos-3.5.0

!apt-get install libgeos-dev

!pip install https://github.com/matplotlib/basemap/archive/master.zip

I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libgeos-3.5.0
E: Couldn't find any package by glob 'libgeos-3.5.0'
E: Couldn't find any package by regex 'libgeos-3.5.0'
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libgeos-dev is already the newest version (3.6.2-1build2).
0 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
Collecting https://github.com/matplotlib/basemap/archive/master.zip
  Using cached https://github.com/matplotlib/basemap/archive/master.zip
ERROR: File "setup.py" not found for legacy project https://github.com/matplotlib/basemap/archive/master.zip.

I then cannot import basemap:

>>> from mpl_toolkits.basemap import Basemap
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'

2 Answers 2

5

Starting with basemap version 1.3.0, you can also install basemap directly using the precompiled binary wheels available in PyPI:

!pip install basemap

In case you need the high-resolution datasets, you have to install them explicitly:

!pip install basemap-data-hires
Sign up to request clarification or add additional context in comments.

Comments

2

There are a couple of errors here.

  1. apt cannot find libgeos

    E: Unable to locate package libgeos-3.5.0

    You may need to find another version of libgeos though I'm not sure what version. Perhaps this should match the installed dev version, 3.6.2?

  2. pip cannot install using the archive that you are providing.

    ERROR: File "setup.py" not found for legacy project https://github.com/matplotlib/basemap/archive/master.zip.

    You can fix this by telling pip specifically what subdirectory it will find the package in:

    pip install git+https://github.com/matplotlib/basemap#subdirectory=packages/basemap
    

    This will allow pip to find the correct package directory.

5 Comments

i am using python 3.8
Also i tried !pip install git+github.com/matplotlib/basemap and its says: ERROR: File "setup.py" not found for legacy project git+github.com/matplotlib/basemap.
It doesn't matter what python version you are using. In part 1 of my answer I am specifically talking about libgeos not python. Part 2 of my answer deals with the basemap package being in a different location, see the #subdirectory=packages/basemap at the end of the GitHub url, which tells pip where to find the package.
Fantastic! what was the version of libgeos that you used? You can edit this answer if you want to add more detail about the steps you took
I used the version you said: 3.6.2 and i do exactly what you said

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.