[PYTHON] I stumbled when I tried to install Basemap, so a memorandum

After browsing at the bookstore, Basemap (A module that allows you to easily plot a map with python. It is very useful when you want to visualize data on a map.) I went back and installed it immediately because there was something that looked cool.

You can draw a cool map with the following simple code. I stumbled upon the installation, so a memo as a memorandum.

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
%matplotlib inline

m = Basemap()
m.bluemarble()

20ca7dd8.png

Execution environment

Python 3.7.6 macOS Mojave 10.14.6 Jupyter Notebook

Installation method

At first.

$ brew install geos

Suddenly stumble below.

$ wget https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz

The following error was thrown. Hmm. .. Apparently there is a problem with wget.

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/bin/wget
  Reason: image not found
zsh: abort      wget 

Check with which. It seems that wget is installed.

$ which wget
/usr/local/bin/wget

Try upgrading wget.

$ brew upgrade wget

==> Upgrading 1 outdated package:
wget 1.20.3 -> 1.20.3_2

The upgrade went well, so I tried again.

$ wget https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz

Download failed.

$ wget https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz
--2020-01-05 19:35:46--  https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz
jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)Is inquiring to DNS... 2001:df0:2ed:feed::feed, 150.65.7.130
jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)|2001:df0:2ed:feed::feed|:Connecting to 443...Connected.
error: jaist.dl.sourceforge.net certificate(Issuer: `CN=Let\'s Encrypt Authority X3,O=Let\'s Encrypt,C=US')Failed to verify:
The issuer's permissions could not be verified.
jaist.dl.sourceforge.To connect to the net without checking safety`--no-check-certificate'Please use.

Ah, I see I see. once again. Try again with `--no-check-certificate'.

$ wget https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz --no-check-certificate

--2020-01-05 19:36:28--  https://jaist.dl.sourceforge.net/project/matplotlib/matplotlib-toolkits/basemap-1.0.7/basemap-1.0.7.tar.gz
jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)Is inquiring to DNS... 2001:df0:2ed:feed::feed, 150.65.7.130
jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)|2001:df0:2ed:feed::feed|:Connecting to 443...Connected.
warning: jaist.dl.sourceforge.net certificate(Issuer: `CN=Let\'s Encrypt Authority X3,O=Let\'s Encrypt,C=US')Failed to verify:
The issuer's permissions could not be verified.
Sent a connection request via HTTP, waiting for a response... 200 OK
length: 129694711 (124M) [application/x-gzip]
`basemap-1.0.7.tar.gz'Saving in

basemap-1.0.7.tar.g 100%[===================>] 123.69M   121KB/s time 21m 6s

2020-01-05 19:57:34 (100 KB/s) - `basemap-1.0.7.tar.gz'Save to[129694711/129694711]

Then execute the following command.

$ tar zxvf basemap-1.0.7.tar.gz
$ cd basemap-1.0.7
$ python setup.py install

I got an error after python setup.py install. .. It's long.


ModuleNotFoundError: No module named 'numpy.random.mtrand'

This time there seems to be a problem with numpy, so uninstall → install.

$ pip3 uninstall numpy

$ pip3 install numpy

After reinstalling, do the following again.

$ python setup.py install

It went well! !! !!

However, when I actually tried to use it with jupyter, I got an error.

ImportError: No module named 'mpl_toolkits.basemap'

If you are looking for various things, you should use this command.

$ pip3 install https://github.com/matplotlib/basemap/archive/master.zip

However, it is not a zip file. Error.

zipfile.BadZipFile: File is not a zip file

Executed because it is possible to drop netCDF4.

$ pip3 install netCDF4

I finally got it! !!

Articles that I used as a reference

Draw a map easily with matplotlib.basemap

When basemap installation fails on python3 (Mojave)

Recommended Posts

I stumbled when I tried to install Basemap, so a memorandum
A memorandum when I tried to get it automatically with selenium
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
When I tried to build a Rails environment on WSL2 (Ubuntu 20.04LTS), I stumbled and fell.
[Python] I tried to implement stable sorting, so make a note
I tried to create a linebot (implementation)
I tried to create a linebot (preparation)
I tried to make a Web API
I tried using pipenv, so a memo
When I tried to scrape using requests in python, I was addicted to SSLError, so a workaround memo
PyPi debut I tried to pip install a library to check Japanese holidays
I tried to make a calculator with Tkinter so I will write it
A memorandum because I stumbled on trying to use MeCab in Python
I tried to build a super-resolution method / ESPCN
I tried to build a super-resolution method / SRCNN ①
I tried to generate a random character string
I tried to build a super-resolution method / SRCNN ③
I tried to build a super-resolution method / SRCNN ②
I tried to make a ○ ✕ game using TensorFlow
I tried to publish my own module so that I can pip install it
When I tried to make a VPC with AWS CDK but couldn't make it
When I tried to create a virtual environment with Python, it didn't work
I failed to install django with pip, so a reminder of the solution
When I tried to connect with SSH, I got a warning about free space.
I tried to debug.
I tried to paste
In IPython, when I tried to see the value, it was a generator, so I came up with it when I was frustrated.
When I tried to introduce python3 to atom, I got stuck
I tried to create a table only with Django
I want to generate a UUID quickly (memorandum) ~ Python ~
I tried to draw a route map with Python
I tried to implement a recommendation system (content-based filtering)
What I did when I stumbled on a Django tutorial
I got a UnicodeDecodeError when pip install on ubuntu
I stumbled upon using MoviePy, so make a note
[Go + Gin] I tried to build a Docker environment
I want to install a package of Php Redis
I tried to automatically generate a password with Python3
A memorandum when an error occurs with pip install
I tried to install scrapy on Anaconda and couldn't
I tried to draw a configuration diagram using Diagrams
I want to collect a lot of images, so I tried using "google image download"
A Python beginner made a chat bot, so I tried to summarize how to make it.
A story that stumbled when I made a chatbot with Transformer
I tried to implement a volume moving average with Quantx
I tried to implement a basic Recurrent Neural Network model
I'm always impatient when ordering a cafe, so I made a React app to solve it.
[Django] A memorandum when you want to communicate asynchronously [Python3]
I tried to learn PredNet
I tried to implement a one-dimensional cellular automaton in Python
I tried to automatically create a report with Markov chain
I tried to organize SVM.
When I tried the AtCoder Beginner Contest, it was a terrible result, so I look back
I tried to implement PCANet
[Markov chain] I tried to read a quote into Python.
Ubuntu blew up when I tried to change my username
I tried to solve a combination optimization problem with Qiskit
I tried "How to get a method decorated in Python"
I tried to get started with Hy ・ Define a class
When I tried to install Ubuntu 18.04, "Initramfs unpacking failed: Decoding failed" was displayed and the startup failed.
I tried to reintroduce Linux