简体   繁体   English

为Python安装GDAL

[英]Installing GDAL for Python

I am trying to install GDAL for python on a Windows XP machine (Python 2.6 currently installed) following the instructions at http://trac.osgeo.org/gdal/wiki/GdalOgrInPython (as is mirrored in a hundred other places). 我尝试按照http://trac.osgeo.org/gdal/wiki/GdalOgrInPython上的说明在Windows XP计算机(当前已安装Python 2.6)上安装适用于python的GDAL(正如在其他一百个地方所反映的那样)。 It says I need both the GDAL source (or Windows binary) and the python bindings. 它说我需要GDAL源代码(或Windows二进制文件)和python绑定。 The python binding are be downloaded from the python cheeseshop ( http://pypi.python.org/pypi/Python_GDAL/1.3.1 ). python绑定是从python Cheeseshop( http://pypi.python.org/pypi/Python_GDAL/1.3.1 )下载的。 I don't see a download link on this page nor can I locate the python binding elsewhere - all instruction I can find seem to point to the same cheeseshop page. 我在此页面上看不到下载链接,也无法在其他位置找到python绑定-我能找到的所有指令似乎都指向相同的Cheeseshop页面。 This seems like I'm either missing something embarrassingly simple or the bindings file has disappeared. 这似乎是我丢失了令人尴尬的简单内容或绑定文件已消失。 Any thoughts on which it is? 有什么想法吗? Thanks. 谢谢。

if python 2.6 is not a pre-requisite the smoothest route to gdal+python is via OSGeo4W . 如果不是python 2.6的先决条件,那么通向gdal + python的最流畅的途径是通过OSGeo4W

To install gdal 1.6 and pythone 2.5 run the setup program, choose Advanced , then select the shell , gdal16 and gdal16-python packages (the gdal 1.7 python package is not yet available). 要安装gdal 1.6和pythone 2.5,请运行安装程序,选择Advanced ,然后选择shellgdal16gdal16-python软件包(gdal 1.7 python软件包尚不可用)。

Start the shell, run gdal16.bat (it will be in PATH) and you're ready. 启动Shell,运行gdal16.bat (它将位于PATH中),您就可以准备好了。

Here is the website: http://pypi.python.org/pypi/GDAL/1.6.0#downloads 这是网站: http : //pypi.python.org/pypi/GDAL/1.6.0#downloads

Just run the .exe for the python version installed on your computer. 只需为计算机上安装的python版本运行.exe。

This is a shameless plug, but you might want to check out my answer in this question: 这是一个无耻的插件,但是您可能想查看我在这个问题上的回答:

Unable to install Python and GDAL (DLL load failed) 无法安装Python和GDAL(DLL加载失败)

The latest GDAL for python seems to be 1.7, ( http://pypi.python.org/pypi/GDAL/1.7.1 ) but contrary to what is says earlier on the cheeseshop page, there''s no windows installer version. 适用于python的最新GDAL似乎是1.7,( http://pypi.python.org/pypi/GDAL/1.7.1 ),但与cheeseshop页面上先前所说的相反,没有Windows安装程序版本。 At the very bottom, there's a tar.gz file with the code in it. 在最底部,有一个tar.gz文件,其中包含代码。

There IS a windows installer program for version 1.6. 有一个用于版本1.6的Windows安装程序。 I don't know if that version runs with python 2.6, though. 我不知道该版本是否与python 2.6一起运行。 I found one source that said as of Feb. 2009, it didn't, but a later note at ucsb.pbworks.com/Using-GDAL-with-Python indicates it does. 我发现一个消息来源说到2009年2月,它没有,但是在ucsb.pbworks.com/Using-GDAL-with-Python上的后来的注解表明确实如此。 I've verified it intalls fine, and I can import it per directions on that page. 我已经证实它可以正常运行,并且可以按照该页面上的说明将其导入。 I haven't done anything more yet. 我什么都没做。

Hope this helps! 希望这可以帮助!

For windows: 对于Windows:

  1. run python from cmd and find your version 从cmd运行python并找到您的版本
  2. go to http://www.gisinternals.com/release.php and download core components + bindings 转到http://www.gisinternals.com/release.php并下载核心组件+绑定
  3. Add core components installation dir to environment's Path (it's been defaulted to C:\\Program Files\\GDAL for me) 将核心组件安装目录添加到环境的路径(对我而言,默认为C:\\ Program Files \\ GDAL)

    1. For windows: 对于Windows:
  4. run python from cmd and find your version 从cmd运行python并找到您的版本

  5. go to http://www.gisinternals.com/release.php and download core components + bindings 转到http://www.gisinternals.com/release.php并下载核心组件+绑定
  6. Add core components installation dir to environment's Path (it's been defaulted to C:\\Program Files\\GDAL for me) 将核心组件安装目录添加到环境的路径(对我而言,默认为C:\\ Program Files \\ GDAL)
  7. add a new system environment 'GDAL_DATA' with 'C:\\Program Files\\GDAL\\data' as value 添加新的系统环境“ GDAL_DATA”,并将“ C:\\ Program Files \\ GDAL \\ data”作为值
  8. add 'from osgeo import gdal' in your code 在您的代码中添加“从osgeo import gdal”

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

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