问题
I am trying to use the Matplotlib Basemap toolkit but am running into a FileNotFoundError
related to epsg
when I try importing it.
I installed it using the following command:
conda install -c conda-forge basemap
Here's my import command:
from mpl_toolkits.basemap import Basemap
Here's the error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-1-d9467465a3b6> in <module>
----> 1 from mpl_toolkits.basemap import Basemap
/anaconda3/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py in <module>
154 # create dictionary that maps epsg codes to Basemap kwargs.
155 pyproj_datadir = os.environ['PROJ_LIB']
--> 156 epsgf = open(os.path.join(pyproj_datadir,'epsg'))
157 epsg_dict={}
158 for line in epsgf:
FileNotFoundError: [Errno 2] No such file or directory: '/anaconda3/share/proj/epsg'
I'm completely new to Basemap, so I'm not sure how to go about fixing this. I'm using Jupyter Notebook to run Python 3.7.3 on macOS Mojave 10.14.6.
Thanks in advance.
回答1:
You are looking for this file: https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/data/epsg
Your PROJ_LIB
env var does not appear to end with .../site-packages
.
Please refer to https://ctcoding.wordpress.com/2019/01/29/solved-proj_lib-error-when-installing-basemap-on-windows-using-anaconda/
Take a look at $ conda info --base
, and then run
$ find `conda info --base` -name epsg
to verify the file was installed in the intended directory.
Adjust PROJ_LIB
to point there.
来源:https://stackoverflow.com/questions/58683341/basemap-wont-import-because-epsg-file-or-directory-cant-be-found-macos-ana