[英]Basemap with Python 3.5 Anaconda on Windows
I use Python 3.5 with latest version of Anaconda on Windows (64 bit). 我在Windows(64位)上使用Python 3.5和最新版本的Anaconda。 I wanted to install Basemap using
conda install basemap
. 我想使用
conda install basemap
安装Basemap。 Apparently there is a conflict between Python 3 and basemap. 显然Python 3和底图之间存在冲突。 After some googling indeed I found that basemap is not supported on Python 3 for Windows users (ex: https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/TjAwi3ilQaU ).
经过一些谷歌搜索后,我发现Python 3 for Windows用户不支持底图(例如: https : //groups.google.com/a/continuum.io/forum/#!topic / anaconda / TjAwi3ilQaU )。
For obvious reasons I do not want to downgrade to Python 2. What would then be the simplest alternative solution? 出于显而易见的原因,我不想降级到Python 2.那么最简单的替代解决方案是什么?
Thanks in advance for the help and advice. 在此先感谢您的帮助和建议。
Referring to the answer of Solly, I have Windows 10, python 3.5.3, Anaconda 64bit, in the Anaconda prompt I entered: 参考Solly的答案,我输入的是Anaconda提示中的Windows 10,python 3.5.3,Anaconda 64bit:
conda install -c conda-forge basemap=1.0.8.dev0
conda install -c conda-forge basemap-data-hires
then the code, taken from Python for Data Science for Dummies , page 193 (Plotting geographical data worked just fine. I wanted to add just a comment to the Solly's answer, but I don't have enough credits to do so. The code is: 那么代码,取自Python for Data Science for Dummies ,第193页(绘制地理数据工作得很好。我想在Solly的答案中添加一个评论,但我没有足够的学分来这样做。代码是:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
austin = (-97.75, 30.25)
hawaii = (-157.8, 21.3)
washington = (-77.01, 38.90)
chicago = (-87.68, 41.83)
losangeles = (-118.25, 34.05)
m = Basemap(projection = 'merc', llcrnrlat=10, urcrnrlat=50,
llcrnrlon=-160, urcrnrlon=-60)
m.drawcoastlines()
m.fillcontinents (color='lightgray', lake_color='lightblue')
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
m.drawmapboundary(fill_color='aqua')
m.drawcounties()
x, y = m(*zip(*[hawaii, austin, washington, chicago, losangeles]))
m.plot(x,y, marker ='o', markersize=6, markerfacecolor='red', linewidth=0)
plt.title('Mercator Projection')
plt.show()
I have solved this several times (last time just now) by downloading it from http://www.lfd.uci.edu/~gohlke/pythonlibs and follow the instructions to install. 我已经从http://www.lfd.uci.edu/~gohlke/pythonlibs下载了几次(上次刚刚解决了这个问题)并按照说明进行安装。 From the anaconda command prompt
从anaconda命令提示符
pip install full_path_to_package
pip install full_path_to_package
For example, if you downloaded basemap-1.1.0-cp36-cp36m-win_amd64.whl, you would run 例如,如果您下载了basemap-1.1.0-cp36-cp36m-win_amd64.whl,那么您将运行
pip install C:\\path\\to\\file\\basemap-1.1.0-cp36-cp36m-win_amd64.whl
pip install C:\\ path \\ to \\ file \\ basemap-1.1.0-cp36-cp36m-win_amd64.whl
Note that the python version of the .whl file must match your python version . 请注意,.whl文件的python版本必须与您的python版本匹配 。 For example,
...-cp36-....
indicates Python 3.6. 例如,
...-cp36-....
表示Python 3.6。 You can find your python version by running the command python --version
. 你可以通过运行命令
python --version
找到你的python版本。
我遇到了同样的问题(Python 3.5和Anaconda)并最终从这里下载了Basemap 1.0.8dev0并使用conda安装它(如链接所述)。
Cartopy is an alternative to Basemap, and it is being actively developed. Cartopy是Basemap的替代品,它正在积极开发中。
There is a nice gallery here: http://scitools.org.uk/cartopy/docs/latest/gallery.html 这里有一个很好的画廊: http : //scitools.org.uk/cartopy/docs/latest/gallery.html
Truth be told I had the same problem and tried to fix it for waaay to long and even tried a python 2 environment with no luck. 真相被告知我遇到了同样的问题,并尝试将其修复为waaay很长时间,甚至尝试了一个没有运气的python 2环境。
Personally just using a python 2 install was way easier and less time consuming. 个人只是使用python 2安装更容易,更省时。 Sorry for the non answer.
很抱歉没有回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.