问题描述
我无法在python中导入mpl_toolkits的底图模块.当我尝试运行从mpl_toolkits.basemap导入底图"时,出现以下错误消息:
I have trouble importing the basemap module of mpl_toolkits in python. I've got following error message when I try to run "from mpl_toolkits.basemap import Basemap":
ModuleNotFoundError:没有名为"mpl_toolkits.basemap"的模块
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'
我在Windows中使用python 3.6.5.
I'm using python 3.6.5 in windows.
我在以下位置找到了相关的问答"无法导入Python底图模块",我已经按照那里的指示进行了操作(例如,源激活MyProfileName,conda安装底图),但没有用.
I've found relevant Q&A in "Python basemap module impossible to import" and I already followed what's instructed there (i.e. source activate MyProfileName, conda install basemap) but it didn't work.
上面的问答中可能已经给出了线索,但是由于我是python的新手,所以我不知道解决方案.
The clue might already be given in the Q&A above but as I'm quite new to python, I couldn't figure out the solution.
推荐答案
我建议安装从零开始的Anaconda 环境.让Anaconda为您处理依赖性.然后,您需要在conda环境中使用以下命令分别安装mpl_toolkits
:
I would recommend installing Anaconda environment from scratch. Let Anaconda handle dependencies for you. Then you need to install mpl_toolkits
separately in your conda environment with:
conda install -c conda-forge basemap-data-hires
另请参见此处.
完成此操作后,执行
from mpl_toolkits.basemap import Basemap
从python控制台
应该可以正常工作.
from python console should work normally.
这篇关于ModuleNotFoundError:没有名为"mpl_toolkits.basemap"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!