[PYTHON] Record addicted to Basemap

I got an error

from mpl_toolkits.basemap import Basemap
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'

I put this in

!pip install mpl_toolkits
!conda install -y basemap

I got an error again

KeyError: 'PROJ_LIB'

It seems that environment variables are needed, so I copied the whole code below and pasted it on jupyter

import os
import conda

conda_file_dir = conda.__file__
conda_dir = conda_file_dir.split('lib')[0]
proj_lib = os.path.join(os.path.join(conda_dir, 'share'), 'proj')
os.environ["PROJ_LIB"] = proj_lib

from mpl_toolkits.basemap import Basemap

It was repaired safely!

I referred to here http://hirotaka-hachiya.hatenablog.com/entry/2019/01/27/220047

Recommended Posts

Record addicted to Basemap
The record I was addicted to when putting MeCab on Heroku
A story addicted to Azure Pipelines
I'm addicted to Python 2D lists
I was addicted to multiprocessing + psycopg2
Record the steps to understand machine learning
I was addicted to pip install mysqlclient
I was addicted to Flask on dotCloud
What I was addicted to Python autorun