Python 在 Windows 上导入 mpl_toolkits.basemap?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34979424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Importing mpl_toolkits.basemap on Windows?
提问by Geena
I have recently started using Python 3.5 and Anaconda on my Windows pc. I am trying to plot a map. However, When I am in my Jupyter notebook and i type the command
我最近开始在我的 Windows 电脑上使用 Python 3.5 和 Anaconda。我正在尝试绘制地图。但是,当我在 Jupyter 笔记本中输入命令时
import mpl_toolkits.basemap
import mpl_toolkits.basemap
I get an error message saying 'no module name' 'mpl_toolkits.basemap'
However, I have the module downloaded and in the same C:\Users\Geena
file as my .matplotlib
, .ipython
, .jupyter
files, etc.
我收到一条错误消息,说“没有模块名称”“mpl_toolkits.basemap”但是,我已经下载了模块,并且与C:\Users\Geena
我的.matplotlib
, .ipython
,.jupyter
文件等位于同一个文件中。
Anyone know how I can fix this?
有谁知道我该如何解决这个问题?
回答by j08lue
When you have Anaconda, you don't downloadmodules anywhere. In your command prompt, you type
当您拥有Anaconda 时,您不会在任何地方下载模块。在命令提示符中,键入
conda install basemap
and it is installed with all its dependencies.
它安装了所有依赖项。
回答by Walter
Anaconda requires an unusual install command for basemap 1.0.7.
https://anaconda.org/anaconda/basemap
Anaconda 对于底图 1.0.7 需要一个不寻常的安装命令。
https://anaconda.org/anaconda/basemap
To install this package with conda run:conda install -c https://conda.anaconda.org/anaconda basemap
要使用 conda 安装此软件包,请运行:conda install -c https://conda.anaconda.org/anaconda basemap
回答by Bruno C. da Silva
Currently, basemap is not compatible with python 3 for windows users. So, if you try conda install basemap
and you have python 3 installed in windows, you'll see a message pointing out that a conflict was found with python 3.
目前,底图与 Windows 用户的 python 3 不兼容。因此,如果您尝试conda install basemap
并在 Windows 中安装了 python 3,您将看到一条消息,指出发现与 python 3 冲突。
I solved this by installing a python 2.7 environment. Try this: http://conda.pydata.org/docs/py2or3.html
我通过安装 python 2.7 环境解决了这个问题。试试这个:http: //conda.pydata.org/docs/py2or3.html
Then you just activate the python 2 environment. For example: activate py27
(py27 is the identifier of my python 2.7 environment).
然后你只需激活python 2环境。例如:activate py27
(py27 是我的python 2.7 环境的标识符)。
After that, you can run conda install basemap
with no conflict.
之后,您可以conda install basemap
无冲突地运行。
回答by Thedoorsalive
I've had this issue with anaconda on my windows 7.
I found the way to fix it with python 3.5:
You need to run with administrator rights "Anaconda Prompt" and in "Anaconda Prompt" run following command:
我在 Windows 7 上遇到了 anaconda 这个问题。
我找到了用 python 3.5 修复它的方法:
您需要以管理员权限运行“Anaconda Prompt”并在“Anaconda Prompt”中运行以下命令:
conda install -c conda-forge basemap-data-hires=1.0.8.dev0
, it will show new packages that you need to install and will ask you to install it - say 'Yes'.
After that new packages will be installed and the issue "import mpl_toolkits.basemap" will be fixed.
,它将显示您需要安装的新软件包并要求您安装它 - 说“是”。
之后将安装新软件包并修复“import mpl_toolkits.basemap”问题。
Thank you.
谢谢你。
回答by Patrick
I just had this issue as well. All you need to do is update matplotlib
by doing the following:
我也刚遇到这个问题。您需要做的就是matplotlib
通过执行以下操作进行更新:
pip install --upgrade matplotlib
mpl_toolkits
is part of matplotlib
and just needs to be updated.
mpl_toolkits
是的一部分matplotlib
,只是需要更新。
回答by Claude
I'm using python 3.6.4on Windows 7 Family Premium (32bit).
我在Windows 7 Family Premium (32bit)上使用python 3.6.4。
Because I was a bit frustrated by the message "no module named 'mpl_toolkits.basemap'", I searched for and tried a dozen of solutions without success : various versions, building from source, problems with VS version, nmake, ... You all know what I mean ;-)
因为我对“没有名为'mpl_toolkits.basemap'的模块”的消息感到有点沮丧,我搜索并尝试了十几种解决方案都没有成功:各种版本,从源代码构建,VS版本问题,nmake,......你都知道我的意思;-)
I finally found a quite simple solution that works perfectly well for me :-) Here it is !
我终于找到了一个非常简单的解决方案,它非常适合我:-) 就是这样!
- from hereI downloaded
basemap?1.1.0?cp36?cp36m?win32.whl
- I changed the current dir to my download dir
- I installed the wheel with
python -m pip basemap?1.1.0?cp36?cp36m?win32.whl
- I did the same for
matplotlib?2.2.3?cp36?cp36m?win32.whl
- 我从这里下载
basemap?1.1.0?cp36?cp36m?win32.whl
- 我将当前目录更改为我的下载目录
- 我安装了车轮
python -m pip basemap?1.1.0?cp36?cp36m?win32.whl
- 我做了同样的
matplotlib?2.2.3?cp36?cp36m?win32.whl
You DO read the versions correctly : matplotlib 2.2.3 and basemap 1.1.0
您确实正确阅读了版本:matplotlib 2.2.3 和底图 1.1.0
Everything works fine for me and I finally can plot OSM POI's on a map of Belgium, without any 'trickery' at import :
一切对我来说都很好,我终于可以在比利时地图上绘制 OSM POI,在导入时没有任何“诡计”:
import requests # to fetch OSM data
import json # to get the response
from mpl_toolkits.basemap import Basemap # ... Belgium is there !
import numpy as np # for arrays
import matplotlib.pyplot as plt # to build the populated map
Big big thanks to Christoph Gohlke(Danke Dir Christoph !) who did all the wonderful job !
非常感谢Christoph Gohlke(Danke Dir Christoph !),他做了所有出色的工作!