rrz0
rrz0

Reputation: 2302

Installing Basemap with Python3.6 on Ubuntu 18.04

I have been trying to get Basemap up and running for the past couple of hours. Following this tutorial I run:

conda install basemap in my venv on Pycharm. Installation goes as planned and I get a message in the termal stating that basemap-1.2.0 has been installed. When running my program:

Downloading and Extracting Packages
proj4-5.0.1          |  7.0 MB | ############################################################################################################################################################################################################################### | 100% 
certifi-2018.10.15   |  139 KB | ############################################################################################################################################################################################################################### | 100% 
libgcc-ng-8.2.0      |  7.6 MB | ############################################################################################################################################################################################################################### | 100% 
libstdcxx-ng-8.2.0   |  2.9 MB | ############################################################################################################################################################################################################################### | 100% 
pyshp-1.2.12         |   35 KB | ############################################################################################################################################################################################################################### | 100% 
pyproj-1.9.5.1       |   64 KB | ############################################################################################################################################################################################################################### | 100% 
openssl-1.0.2p       |  3.5 MB | ############################################################################################################################################################################################################################### | 100% 
conda-4.5.11         |  1.0 MB | ############################################################################################################################################################################################################################### | 100% 
geos-3.6.2           |  1.6 MB | ############################################################################################################################################################################################################################### | 100% 
basemap-1.2.0        | 15.2 MB | ############################################################################################################################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done


 Traceback (most recent call last):
  File "/home/PycharmProjects/first_prog/venv/test.py", line 5, in <module>
    from mpl_toolkits.basemap import Basemap
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'

I saw some answers stating that Basemap should be installed from source instead of using conda, so I installed Basemap from source.

I first installed geos. From the basemap-1.x.x directory, I changed into the geos directory and set the GEOS_DIR environment variable.

basemap-1.x.x $ cd geos-3.3.3
basemap-1.x.x/geos-3.3.3 $ export GEOS_DIR=~/
basemap-1.x.x/geos-3.3.3 $ ./configure --prefix=$GEOS_DIR

basemap-1.x.x/geos-3.3.3 $ make  <---- ERROR HERE
basemap-1.x.x/geos-3.3.3 $ make install

On running the make command I get this error:

Makefile:373: recipe for target 'IndexedPointInAreaLocator.lo' failed
make[4]: *** [IndexedPointInAreaLocator.lo] Error 1
make[4]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm/locate'
Makefile:392: recipe for target 'check-recursive' failed
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm/locate'
Makefile:444: recipe for target 'check-recursive' failed
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src/algorithm'
Makefile:476: recipe for target 'check-recursive' failed
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory '/home/Downloads/basemap-1.0.7/geos-3.3.3/src'
Makefile:368: recipe for target 'check-recursive' failed
make: *** [check-recursive] Error 1

There are several solutions to this error but none have worked. I tried using CheckInstall, followed this thread, tried to use DNF, followed these commands and much more, but nothing worked.

ImportError: Ubuntu 16.04.3 - Installing basemap module on python 2.7.12 is related, but the error persists.

installing Basemap is related, to the make error, but make: *** [all-recursive] Error 1 persists.

What am I doing wrong? Is it actually this hard to install Basemap? I am completely stuck here, Any help is greatly appreciated.

Upvotes: 3

Views: 5818

Answers (3)

Yiyu Ni
Yiyu Ni

Reputation: 1

I encountered exact the same problem: even the same error. And seems that when I was using a higher version of g++/gcc(~v7.4) to compile a older version of geos(~3.3.0 for me), here comes out this problem.

Then I go to https://trac.osgeo.org/geos/ and get the geos of version 3.8.0, and still using normal gcc/g++, and everything is just fine.

Hope this might help you, and the others.

Upvotes: 0

Thomas Dickson
Thomas Dickson

Reputation: 363

I found this script worked for me. It is slightly different to the other answer in that it downloads and installs basemap without having to download it separately.

pip install --upgrade --user matplotlib numpy pyproj pyshp OWSLib Pillow 
sudo apt-get update 
sudo apt install libgeos-dev 
pip install --user https://github.com/matplotlib/basemap/archive/master.zip

Upvotes: 1

Patol75
Patol75

Reputation: 4547

The method below should work. You can download the archive here.

pip install --upgrade --user matplotlib numpy pyproj pyshp OWSLib Pillow
sudo apt install libgeos-dev
pip install --user --upgrade basemap-1.2.0rel.tar.gz

Upvotes: 1

Related Questions