1

I was wondering how to build the gdal python binding from source using MinGW. In particular, I need to install python utility scripts such as gdal_calc.py.

I've searched around and found this question about Installing GDAL with Python on windows?, but it was about installing gdal binaries. I need to compile from source because I have other libraries in my MinGW/MSYS.

So far, I have downloaded gdal-1.11.2.tar.gz, and I did:

./configure --with-python=/c/Python27/ArcGIS10.2/python.exe
make && make install

/c/Python27/ArcGIS10.2/python.exe above is the python binary from ArcGIS 10.2. I also followed http://trac.osgeo.org/gdal/wiki/BuildingWithMinGW to edit $PYTHON_ROOT\lib\distutils\ccompiler.py.

But I cannot get past the last step make install. After make, I have ./swig/python/scripts/gdal_calc.py in the make folder, but gdal_calc.py is not installed to the msys folder with make install.

I was wondering if anyone can suggest the right way to compile from source here?

The error message I got during make install was:

make[1]: Entering directory `/c/temp/src/gdal-1.11.2/swig'
for dir in python ; do (cd $dir; make install) || exit; done
make[2]: Entering directory `/c/temp/src/gdal-1.11.2/swig/python'
/c/Python27/ArcGIS10.2/python.exe setup.py install --prefix=/usr/local
running install
running build
running build_py
running build_ext
Traceback (most recent call last):
  File "setup.py", line 320, in <module> ext_modules = ext_modules )
  File "c:\Python27\ArcGIS10.2\lib\distutils\core.py", line 152, in setup dist.run_commands()
  File "c:\Python27\ArcGIS10.2\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  ...
  File "setup.py", line 176, in get_gdal_config
    return fetch_config(option)
  File "setup.py", line 129, in fetch_config
    raise gdal_config_error, e""")
  File "<string>", line 4, in <module>
__main__.gdal_config_error: [Error 2] The system cannot find the file specified
make[2]: *** [install] Error 1
make[2]: Leaving directory `/c/temp/src/gdal-1.11.2/swig/python'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/c/temp/src/gdal-1.11.2/swig'
make: *** [install-actions] Error 2
  • Were you able to compile without Python (i.e. no --with-python)? What extra library do you need that was not available? – Mike T Jun 29 '15 at 4:24
  • Yes. Without python ./configure && make && make install works fine in MSYS. With python, it fails only the last step. I had GEOS sometimes, but that does not affect this error. – tinlyx Jun 29 '15 at 5:26
  • I don't think the "cannot reproduce" close reason applies to the question. Nobody reported success, and it's still relevant to have gdal python binding. – tinlyx Oct 31 '17 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.