I am using Python3.6 and MacOS 10.13.2(Beta) but should work with similar setups.
First create and activate your virtual environment, by default mine is created on top of Python3.6.
~ ❯❯❯ mkvirtualenv basemap-virtualenv [...] Installing setuptools, pip, wheel...done. [...] (basemap-virtualenv) ~ ❯❯❯ cd Desktop (basemap-virtualenv) ~/Desktop ❯❯❯ curl https://codeload.github.com/matplotlib/basemap/tar.gz/v1.1.0 -o basemap-v1.1.0.tar.gz
Note that I am using the latest version 1.1.0 as of the time of writing this, but you should use the latest available on https://github.com/matplotlib/basemap/releases.
Let’s start the installation
(basemap-virtualenv) ~/Desktop ❯❯❯ tar -xvf basemap-v1.1.0.tar.gz (basemap-virtualenv) ~/Desktop ❯❯❯ cd basemap-1.1.0/geos-3.3.3/ (basemap-virtualenv) ~/D/b/geos-3.3.3 ❯❯❯ export GEOS_DIR=/usr/local (basemap-virtualenv) ~/D/b/geos-3.3.3 ❯❯❯ ./configure --prefix=$GEOS_DIR (basemap-virtualenv) ~/D/b/geos-3.3.3 ❯❯❯ make; make install
After this geos library is installed, let’s jump onto installing basemap.
(basemap-virtualenv) ~/D/basemap-1.1.0 ❯❯❯ pip install numpy (basemap-virtualenv) ~/D/basemap-1.1.0 ❯❯❯ pip install pyproj (basemap-virtualenv) ~/D/basemap-1.1.0 ❯❯❯ pip install pyshp (basemap-virtualenv) ~/D/basemap-1.1.0 ❯❯❯ python setup.py install [...] customize UnixCCompiler customize UnixCCompiler using build_ext building '_geoslib' extension compiling C sources C compiler: clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes compile options: '-I/usr/local/include -I['/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include'] -I/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include -I/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c' clang: src/_geoslib.c zsh:1: no matches found: -I[/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include] zsh:1: no matches found: -I[/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include] error: Command "clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I['/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include'] -I/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include -I/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/_geoslib.c -o build/temp.macosx-10.12-x86_64-3.6/src/_geoslib.o -MMD -MF build/temp.macosx-10.12-x86_64-3.6/src/_geoslib.o.d" failed with exit status 1
As we can see, the installation out of the box is failing. More specifically, the command
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes compile options: '-I/usr/local/include -I['/Users/myself/.virtualenvs/basemap-virtualenv/lib/python3.6/site-packages/numpy/core/include'] ...
The reason lies in a bug on setup.py. If you read the error, you will see how we are trying to include (-I) a path, but instead, we are passing a python array with a single string inside. To fix this go to this line:
geos_include_dirs = [os.path.join(GEOS_dir,'include'),inc_dirs]
and change it to:
geos_include_dirs = [os.path.join(GEOS_dir,'include'),inc_dirs[0]]
After that python setup.py install succeeds.
[…] Install matplotlib basemap on virtualenv […]
[…] Install matplotlib basemap on virtualenv […]
[…] Install matplotlib basemap on virtualenv […]
¿how can i change the line to geos_include_dirs = [os.path.join(GEOS_dir,’include’),inc_dirs[0]]? i don’t fine this line … i’m new with all terminal stuff, so some help would be really nice 🙂
It’s inside the basemap-1.1.0 directory, the file name is setup.py.
Good luck.
I followed all these above steps. And I am getting a different error, as shown below:
Command “gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/shyammk/anaconda3/include -arch x86_64 -I/Users/shyammk/anaconda3/include -arch x86_64 -I/usr/local/include -I/Users/shyammk/OneDrive/SELF_DEV/Projects/BOI/EngineB/Sentinel/sentinel-aero-filter/sentinel_venv/lib/python3.7/site-packages/numpy/core/include -I/Users/shyammk/OneDrive/SELF_DEV/Projects/BOI/EngineB/Sentinel/sentinel-aero-filter/sentinel_venv/lib/python3.7/site-packages/numpy/core/include -I/Users/shyammk/OneDrive/SELF_DEV/Projects/BOI/EngineB/Sentinel/sentinel-aero-filter/sentinel_venv/include -I/Users/shyammk/anaconda3/include/python3.7m -c src/_geoslib.c -o build/temp.macosx-10.7-x86_64-3.7/src/_geoslib.o -MMD -MF build/temp.macosx-10.7-x86_64-3.7/src/_geoslib.o.d” failed with exit status 1
Any inputs on how to fix this? Thanks in advance.