Can't import GDAL into Python (2.5 or 2.6)

Vincent Habchi vince at macports.org
Fri Aug 20 07:42:20 PDT 2010


Hi JP,

> That didn't seem to resolve the problem, but i am not sure I installed everything properly. I am a little out of my depth as far as the ins-and-outs of Macports packages go. Maybe someone else can give it a try and see if it works for them (if they have the problem - since no one else seemed to have this problem here, maybe there is just something messed up with my configuration).

Sorry it did not work. It is definitely not a problem with your configuration. With the current GNUMakefile in the swig/python directory of gdal, the python plugins go in /opt/local/lib/python26/… instead of /opt/local/Library/… so that is definitely a bug.

> Also, was the patch supposed to have a "." at the end of it? I took it off, and it overwrote the existing patch file, but that may have been a mistake.

Strange, as I can see no '.' at the end of my patch file. Anyhow, I'll file a bug report/enhancement request asking to bump to 1.7.2 and solving this bug.

My own version works, as far as libspatialite is buggy:

PM: python
Python 2.6.5 (r265:79063, Aug 16 2010, 14:14:17) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/osgeo/_gdal.so, 2): Symbol not found: _locale_charset
  Referenced from: /opt/local/lib/libspatialite.1.dylib
  Expected in: flat namespace
 in /opt/local/lib/libspatialite.1.dylib
>>> 

I hope we will integrate the patches quickly into the mainstream so that you can recompile it without to worry about overriding files here and there.

Have a nice week-end meanwhile
Vincent


More information about the macports-users mailing list