Basemap won't import because 'epsg' fi

2020-06-29 17:32发布

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条回答
Fickle 薄情
2楼-- · 2020-06-29 18:01

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.

查看更多
登录 后发表回答