简体   繁体   English

在Windows上使用Python 3.5 Anaconda的底图

[英]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.那么最简单的替代解决方案是什么?

  • Is there an alternative package similar to basemap for ploting maps, etc.? 是否有类似于底图的替代包用于绘制地图等?
  • Should I use a second environment which uses Python 2 and basemap? 我应该使用第二个使用Python 2和底图的环境吗? I have never done that but it seems possible ( http://conda.pydata.org/docs/py2or3.html ). 我从来没有这样做但似乎有可能( http://conda.pydata.org/docs/py2or3.html )。 Is it "safe"? 它“安全”吗? Should I install again all the other packages (matplotlib, numpy, etc.) on the second environment? 我应该在第二个环境中再次安装所有其他软件包(matplotlib,numpy等)吗?

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. 很抱歉没有回答。

The below information is for Mac OS: 以下信息适用于Mac OS:

  1. Downloaded from here ! 这里下载!
  2. Run conda install -c conda-forge basemap-1.2.0-py37h9622e30_3.tar.bz2 运行conda install -c conda-forge basemap-1.2.0-py37h9622e30_3.tar.bz2
  3. 在此输入图像描述
  4. Done 完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM