底图将不会导入,因为找不到"epsg"文件或目录(MacOS,Anaconda,Jupyter Notebook) [英] Basemap won't import because 'epsg' file or directory can't be found (MacOS, Anaconda, Jupyter Notebook)
问题描述
我正在尝试使用Matplotlib底图工具包,但是在尝试导入它时遇到与epsg
相关的FileNotFoundError
.
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
这是我的导入命令:
from mpl_toolkits.basemap import Basemap
这是错误:
---------------------------------------------------------------------------
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'
我对Basemap完全陌生,所以我不确定如何解决此问题.我正在使用Jupyter Notebook在macOS Mojave 10.14.6上运行Python 3.7.3.
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.
谢谢.
推荐答案
您正在寻找以下文件: https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/data/epsg
You are looking for this file: https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/data/epsg
您的PROJ_LIB
env var似乎不以.../site-packages
结尾.
请参考
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/
看看$ conda info --base
,然后运行
$ find `conda info --base` -name epsg
验证文件已安装在预期的目录中.
调整PROJ_LIB
指向那里.
to verify the file was installed in the intended directory.
Adjust PROJ_LIB
to point there.
这篇关于底图将不会导入,因为找不到"epsg"文件或目录(MacOS,Anaconda,Jupyter Notebook)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!