编程语言
首页 > 编程语言> > python – PyCharm中的底图导入错误 – KeyError:’PROJ_LIB’

python – PyCharm中的底图导入错误 – KeyError:’PROJ_LIB’

作者:互联网

我尝试使用Basemap包来绘制PyCharm的地图,但是我遇到了问题

from mpl_toolkits.basemap import Basemap`

跟踪追溯如下:

Traceback (most recent call last):
File "/Users/yupeipei/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-0a24a3a77efd>", line 7, in <module>
    from mpl_toolkits.basemap import Basemap
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/yupeipei/anaconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py", line 146, in <module>
    pyproj_datadir = os.environ['PROJ_LIB']
  File "/Users/yupeipei/anaconda3/lib/python3.6/os.py", line 669, in __ getitem__
    raise KeyError(key) from None
KeyError: 'PROJ_LIB'

我对PyCharm上的这个错误感到困惑,因为相同的脚本在Jupyter或Spyder上运行正常! PyCharm的环境是../anaconda3/lib/python3.6,其中与anaconda相同.

有没有人遇到过这个错误?

任何人都可以帮我解决这个错误吗?

解决方法:

关于mewahl的评论我已经添加到我的.bashrc(我使用bash):

export PROJ_LIB=/path/to/your/instalation/of/anaconda/share/proj/

现在底图(和其他工作).

标签:matplotlib-basemap,python,python-3-x,pycharm
来源: https://codeday.me/bug/20190928/1828369.html