[postgis-users] GDAL problems (Kyngesbury GDAL)

William Kyngesburye woklist at kyngchaos.com
Sat Dec 28 09:38:25 PST 2013


The compile flag to set the GDAL include dir is wrong for the framework.  It seems to be assuming that the framework is a 'nix lib/include structure, but really the include dir is named "Headers".  Odd that it uses supposedly gdal-config, but doesn't get the -cflags from it that have the correct include dir.

I see that Tim's instructions actually call for using --include-dirs=/Library/Frameworks/GDAL.framework/Versions/1.9/Headers/


I wonder: Tim, what is it about the "virtual environment" that makes the existing GDAL python in the framework not work? (I don't know anything about python virtual env)


On Dec 27, 2013, at 10:33 PM, Dheeraj Chand wrote:

> Hi, all,
> 
> I was working on a project, that at a high level, can be described as :
> 
> 1. Connect Python to PostGIS,
> 2. Grab spatial tables' data,
> 3. *PROCESS*,
> 4. Spit out shapefiles.
> 
> In the process of doing this, I was trying to use the Python GDAL library in a new virtualenv called geo, but I got these errors.  I am using William Kyngesbury's GDAL 1.10 for OS X, and I'm running into crazy errors.  I am following the instructions from here (http://linfiniti.com/2013/02/installing-python-gdal-into-a-python-virtualenv-in-osx/), and this is what happened in my shell.
> 
> Can anyone help me out?
> 
> Best,
> 
> -dx
> 
> 
> -----------------------------------
> REINHEIT:~ dheerajchand$ cd ~/Python_Environments/geo/
> REINHEIT:geo dheerajchand$ cd build/
> REINHEIT:build dheerajchand$ ls
> total 8
> drwxr-xr-x   4 dheerajchand  staff   136B Dec 27 18:10 ./
> drwxr-xr-x   7 dheerajchand  staff   238B Dec 27 18:10 ../
> drwxr-xr-x  22 dheerajchand  staff   748B Dec 27 18:10 GDAL/
> -rw-r--r--   1 dheerajchand  staff   185B Dec 27 18:10 pip-delete-this-directory.txt
> /Users/dheerajchand/Python_Environments/geo/build
> REINHEIT:build dheerajchand$ source ~/Python_Environments/geo/bin/activate
> (geo)REINHEIT:build dheerajchand$ pip install --no-install GDAL
> Downloading/unpacking GDAL
>   Running setup.py egg_info for package GDAL
> 
> Successfully downloaded GDAL
> (geo)REINHEIT:build dheerajchand$ pip freeze
> numpy==1.8.0
> psycopg2==2.5.1
> wsgiref==0.1.2
> (geo)REINHEIT:build dheerajchand$ sudo find / -name gdal-config
> Password:
> find: /dev/fd/3: Not a directory
> find: /dev/fd/4: Not a directory
> /Library/Frameworks/GDAL.framework/Versions/1.10/Programs/gdal-config
> /Library/Frameworks/GDAL.framework/Versions/1.10/unix/bin/gdal-config
> /Library/Frameworks/GDAL.framework/Versions/1.7/Programs/gdal-config
> /Library/Frameworks/GDAL.framework/Versions/1.8/Programs/gdal-config
> /Library/Frameworks/GDAL.framework/Versions/1.9/Programs/gdal-config
> /Library/Frameworks/GDAL.framework/Versions/1.9/unix/bin/gdal-config
> /opt/opengeo/pgsql/9.1/bin/gdal-config
> (geo)REINHEIT:build dheerajchand$ cd GDAL/
> (geo)REINHEIT:GDAL dheerajchand$ python setup.py build_ext \
> >  --gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.10/Programs/gdal-config \
> >  --library-dirs=/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/
> running build_ext
> gcc-4.2 not found, using clang instead
> building 'osgeo._gdal' extension
> creating build
> creating build/temp.macosx-10.6-intel-2.7
> creating build/temp.macosx-10.6-intel-2.7/extensions
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-2.7/extensions/gdal_wrap.o
> extensions/gdal_wrap.cpp:2853:10: fatal error: 'cpl_port.h' file not found
> #include "cpl_port.h"
>          ^
> 1 error generated.
> error: command 'clang' failed with exit status 1
> (geo)REINHEIT:GDAL dheerajchand$ python setup.py build_ext  --gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.10/Programs/gdal-config  --library-dirs=/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ --include-dirs=/Library/Frameworks/GDAL.framework/Versions/1.
> 1.10/ 1.7/  1.8/  1.9/
> (geo)REINHEIT:GDAL dheerajchand$ python setup.py build_ext  --gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.10/Programs/gdal-config  --library-dirs=/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ --include-dirs=/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/
> running build_ext
> gcc-4.2 not found, using clang instead
> building 'osgeo._gdal' extension
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-2.7/extensions/gdal_wrap.o
> extensions/gdal_wrap.cpp:7501:31: warning: conversion from string literal to
>       'char *' is deprecated [-Wdeprecated-writable-strings]
>         PyObject *item_list = PyMapping_Items( obj1 );
>                               ^
> /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:1354:50: note:
>       expanded from macro 'PyMapping_Items'
> #define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
>                                                  ^
> 1 warning generated.
> extensions/gdal_wrap.cpp:7501:31: warning: conversion from string literal to
>       'char *' is deprecated [-Wdeprecated-writable-strings]
>         PyObject *item_list = PyMapping_Items( obj1 );
>                               ^
> /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:1354:50: note:
>       expanded from macro 'PyMapping_Items'
> #define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
>                                                  ^
> 1 warning generated.
> creating build/lib.macosx-10.6-intel-2.7
> creating build/lib.macosx-10.6-intel-2.7/osgeo
> c++ -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/extensions/gdal_wrap.o -L/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ -L/Library/Frameworks/GDAL.framework/Versions/1.10/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_gdal.so
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> building 'osgeo._gdalconst' extension
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/gdalconst_wrap.c -o build/temp.macosx-10.6-intel-2.7/extensions/gdalconst_wrap.o
> clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/extensions/gdalconst_wrap.o -L/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ -L/Library/Frameworks/GDAL.framework/Versions/1.10/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_gdalconst.so
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> building 'osgeo._osr' extension
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/osr_wrap.cpp -o build/temp.macosx-10.6-intel-2.7/extensions/osr_wrap.o
> c++ -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/extensions/osr_wrap.o -L/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ -L/Library/Frameworks/GDAL.framework/Versions/1.10/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_osr.so
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> building 'osgeo._ogr' extension
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/ogr_wrap.cpp -o build/temp.macosx-10.6-intel-2.7/extensions/ogr_wrap.o
> c++ -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/extensions/ogr_wrap.o -L/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ -L/Library/Frameworks/GDAL.framework/Versions/1.10/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_ogr.so
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> building 'osgeo._gdal_array' extension
> clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/GDAL.framework/Versions/1.10/Headers/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.10/include -c extensions/gdal_array_wrap.cpp -o build/temp.macosx-10.6-intel-2.7/extensions/gdal_array_wrap.o
> In file included from extensions/gdal_array_wrap.cpp:2899:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1760:
> /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning:
>       "Using deprecated NumPy API, disable it by "          "#defining
>       NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
> #warning "Using deprecated NumPy API, disable it by " \
>  ^
> 1 warning generated.
> In file included from extensions/gdal_array_wrap.cpp:2899:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17:
> In file included from /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1760:
> /Users/dheerajchand/Python_Environments/geo/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning:
>       "Using deprecated NumPy API, disable it by "          "#defining
>       NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
> #warning "Using deprecated NumPy API, disable it by " \
>  ^
> 1 warning generated.
> c++ -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/extensions/gdal_array_wrap.o -L/Library/Frameworks/GDAL.framework/Versions/1.10/unix/lib/ -L/Library/Frameworks/GDAL.framework/Versions/1.10/lib -lgdal -o build/lib.macosx-10.6-intel-2.7/osgeo/_gdal_array.so
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> ld: warning: directory not found for option '-L/Library/Frameworks/GDAL.framework/Versions/1.10/lib'
> (geo)REINHEIT:GDAL dheerajchand$ pip install --no-download GDAL
> Installing collected packages: GDAL
>   Running setup.py install for GDAL
>     gcc-4.2 not found, using clang instead
> 
> Successfully installed GDAL
> Cleaning up...
> (geo)REINHEIT:GDAL dheerajchand$ python
> Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from osgeo import gdal
> >>> gdal.__version__
> Segmentation fault: 11
> (geo)REINHEIT:GDAL dheerajchand$
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"History is an illusion caused by the passage of time, and time is an illusion caused by the passage of history."

- Hitchhiker's Guide to the Galaxy




More information about the postgis-users mailing list