Home > Software engineering >  Cannot install matplotlib basemap
Cannot install matplotlib basemap

Time:01-05

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'

CodePudding user response:

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.

  •  Tags:  
  • Related