问题描述
我是Python Noob. (使用Mac OS 10.12和Python 3.7)我正在尝试使用mpl_toolkits.basemap
I am a Python Noob. (Using Mac OS 10.12 & Python 3.7)I'm trying to use mpl_toolkits.basemap
执行代码
from mpl_toolkits.basemap import Basemap
我用Google搜索了matplotlib的方法并成功安装了它.但是,尽管可以在Mac终端上运行从mpl_toolkits.basemap import底图",
I googled the way to get matplotlib and successfully installed it.However, while it's possible to run "from mpl_toolkits.basemap import Basemap" in terminal on mac,
如果我在IDLE中运行命令,则无法加载.
it fails to be loaded if I run the command within IDLE.
然后,我用Google搜索找出了问题所在,并得到了以下提示:如果我正确安装了底图,就可以解决.
Then, I googled to figure out the issue and got the hint that it could be resolved if I install Basemap properly.
要安装底图,我认为我需要使用"FINK".
To install Basemap, I think I need to go with "FINK".
但是,Fink仅在我的版本为10.12时才可用于10.5操作系统.而且FINK网站说在升级FINK之前不要更新操作系统.但是,对我来说太迟了.原因我很早以前就更新了操作系统,最近又开始使用Mac学习Python.
However, Fink is only available up to 10.5 OS while mine is 10.12.And FINK website says do not update OS before upgrading FINK. However, it's too late for me. Cause I updated my OS longtime ago and recently I started to learn Python Using Mac.
所以我想,如果有一种方法可以不使用apt-get来安装Basemap,(以下代码来自"无法导入的Python底图模块")
So I guess, if there is a way to install Basemap not using apt-get,(the codes below is from "Python basemap module impossible to import")
sudo apt-get install libgeos-3.5.0
sudo apt-get install libgeos-dev
sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
我认为我的问题可以解决.由于我真的是菜鸟,因此我不确定这是我无法从mpl_toolkits.basemap import底图"失败的原因.
I think my issue could be cleared. Since I'm really really noob, I'm not sure this is the reason for my failing in "from mpl_toolkits.basemap import Basemap".
到目前为止,我尝试过的是
What I tried so far is
1)brew install basemap
错误
1) brew install basemap
with the error of
2)pip install basemap
错误
2) pip install basemap
with the error of
3)sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
3) sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
,错误为
4)conda install basemap
并显示以下消息
4) conda install basemap
with the following message of
5)conda install -c conda-forge basemap
并显示以下消息
5) conda install -c conda-forge basemap
with the following message
任何人都可以帮助正确安装底图以便我可以运行
Can anyone help to install basemap properly so that I could run
"from mpl_toolkits.basemap import Basemap"
在我的IDLe中?我的IDLE Sheel一直在说
in my IDLe? My IDLE Sheel keeps saying
我的终端在运行代码时没有问题.
while my terminal doesn't have problem with running the code.
请先欣赏一下
推荐答案
有运气吗?我也花了一天的时间与之抗争.当我尝试下载较旧版本的底图时,我获得了最大的成功.
any luck? I spent the day battling this as well. I had the most success when I tried downloading an older version of basemap.
我使用的是python 2.7,它可以正常工作sudo -H pip2 install https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz
I was using python 2.7 and this worked okay sudo -H pip2 install https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz
对于python 3,请尝试将pip2
替换为pip3
或pip
.
For python 3 try replacing pip2
with pip3
or pip
.
这篇关于在Mac上安装底图时没有芬克(我尝试了可以用Google进行的所有操作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!