Spyder无法导入底图

时间:2018-11-19 07:15:00

标签: python matplotlib spyder matplotlib-basemap

我无法执行netCDF文件并在spyder中出错。这是我运行test.py脚本时得到的:

runfile('C:/Users/WINDOWS 8/Desktop/Testpython/test1.py', wdir='C:/Users/WINDOWS 8/Desktop/Testpython')
Traceback (most recent call last):

File "<ipython-input-1-c58f888280ee>", line 1, in <module>
runfile('C:/Users/WINDOWS 8/Desktop/Testpython/test1.py', wdir='C:/Users/WINDOWS 8/Desktop/Testpython')

File "C:\ProgramData\Anaconda2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 93, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

File "C:/Users/WINDOWS 8/Desktop/Testpython/test1.py", line 3, in <module>
from mpl_toolkits.basemap import Basemap

File "C:\ProgramData\Anaconda2\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 155, in <module>
pyproj_datadir = os.environ['PROJ_LIB']

File "C:\ProgramData\Anaconda2\lib\os.py", line 425, in __getitem__
return self.data[key.upper()]
KeyError: 'PROJ_LIB'

我试图从apt-get,conda卸载源中的重新安装底图,但是它没有任何改变:我无法导入底图。

谢谢您的帮助

1 个答案:

答案 0 :(得分:0)

在我看来该错误消息与pyproj模块有关。您是否已安装所有最新的底图依赖关系?您可以使用此命令进行检查(需要pip)

127 1 ['second', 'episode', 'fever', 'last', 'week']

这实际上是一个与conda相关的问题,请参阅here