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()
Python 3.7.6 macOS Mojave 10.14.6 Jupyter Notebook
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! !!
Draw a map easily with matplotlib.basemap
When basemap installation fails on python3 (Mojave)
Recommended Posts