Installing GDAL / OGR for Python on Windows

المشرف العام

Administrator
طاقم الإدارة
Installing GDAL/OGR for Python on Windows is now even easier!



Christoph Gohlke, through his Unofficial Windows Binaries for Python Extension Packages, provides a number of libraries as Python Wheel files, which you can easily install to your desired Python… Unlike some other installers this installer includes GDAL, its data and the Python bindings all in the one installer.

Overview

1. Determine your desired Python install and version
2. Download the GDAL installer/bindings
3. Install
4. Notes


1. Determine your desired Python install and version

See the post on Locating Python and adding it to your system Path for information about how to find the Python install you wish to use (you do not need to add it to your system Path to continue with the steps below).

Once you have figured out which Python you are going to use, open the Python interpreter in your normal way (or double click on its python.exe). It will print version information at the top when it opens, for example: Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32

The important information is highlighted above: my version is Python 2.7 (the additional .10 is not important) and it is 32 bit.

2. Download the GDAL installer/bindings

Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and select the appropriate download corresponding to your Python version. Unless you specifically need an older version you might as well download the latest GDAL version. The filename has the format:

GDAL-[version]-cp[python version]-none-[architecture].whlSo, based on the example above, I would download:

GDAL-2.0.2-cp27-none-win32.whl3. Install

Wheel files are installed using*pip. The syntax is (if pip is on your system path):

pip install GDAL-[etc.].whlOtherwise:

[path to your desired python]\Scripts\pip install GDAL-[etc.].whl4. Notes

Test your install by opening Python and entering:


import ogrThis should throw no errors.

If you already have GDAL installed you may have issues regarding GDAL’s data. You may need to edit your GDAL_DATA environment variable; see the old Installing GDAL (and OGR) for Python on Windows for details in the relevant section, where the GDAL data path of the new install is:

[path to the relevant python]\Lib\site-packages\osgeo\data\gdal




أكثر...
 
أعلى