gpt4 book ai didi

python - 如何避免导入 basemap 时出现 PROJ_LIB 错误?

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:35 24 4
gpt4 key购买 nike

我尝试在 Python 中按如下方式导入 basemap :

from mpl_toolkits.basemap import Basemap

我收到以下错误:

Traceback (most recent call last):

File "<ipython-input-16-880204a64918>", line 2, in <module>
from mpl_toolkits.basemap import Basemap

File "C:\Users\bakhadher\AppData\Local\Continuum\anaconda3\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 155, in <module>
pyproj_datadir = os.environ['PROJ_LIB']

File "C:\Users\bakhadher\AppData\Local\Continuum\anaconda3\lib\os.py", line 678, in __getitem__
raise KeyError(key) from None

KeyError: 'PROJ_LIB'

最佳答案

来自这里:https://github.com/conda-forge/basemap-feedstock/issues/30#issuecomment-423512069

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```

关于python - 如何避免导入 basemap 时出现 PROJ_LIB 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54201946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com