[gdal-dev] can't import osgeo or gdal in python

William Kyngesburye woklist at kyngchaos.com
Mon Sep 20 22:53:01 EDT 2010


On Sep 20, 2010, at 9:37 PM, Ivan Lucena wrote:

> I got some good news!
> 
> It is working pretty good. See:
> 
> Last login: Mon Sep 20 19:08:28 on ttys002
> turtlebowl:~ ilucena$ python
> Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from osgeo import gdal
>>>> drv = gdal.GetDriverByName("GTIFF")
>>>> print drv.GetDescription()
> GTiff
>>>> 
> 
> In my case, I install Python 2.7 so it was easier to notice that I was not running Apples's installation of Python 2.6.
> 
> Anyway, the instruction are relatively accurate at issue7107 but basically, all you need to do is that:
> 
> ln -s /usr/bin/python2.6 /usr/bin/python
> 
Ah, something must have deleted this file.  This exists on a clean OS X install.  And, more correctly, the files are more complicated:

/usr/bin/python and its companions /usr/bin/pythonw are Apple-special python executables.  These will drop to 32bit mode when based on an environment variable.  This is non-standard behavior (for python), and strangely these executables don't respond to the arch command to force an executable to run with a given architecture (the standard way for any program).  I think pythonw may also automatically always drop to 32bit mode because it assume you're running a wxpython GUI program, which is 32bit-only.

If these were deleted somehow, the only way to recover them (for out-of-the-box OS X Python behavior) is to reinstall the system or recover them from a backup.

/usr/bin/python2.6 and other variations of pythonw and 2.5 and 2.6 versions are all symlinks to the executable in the python framework.  These respond normally to the arch command.  These are the same as what you get with a source build or from the python.org installers.

> Note that running "make generate; setup.py build; setup.py install" with Apple's Python is a little bit scarier now, full of 
> warning but it works.
> 
> Regards,
> 
> Ivan
> 
>> -------Original Message-------
>> From: Ivan Lucena <ivan.lucena at pmldnet.com>
>> To: William Kyngesburye <kyngchaos at kyngchaos.com>
>> Cc: gdal-dev <gdal-dev at lists.osgeo.org>
>> Subject: Re: [gdal-dev] can't import osgeo or gdal in python
>> Sent: Sep 20 '10 20:43
>> 
>> Well, I am following other lead.
>> 
>> I am trying to uninstall the python.org 2.7 and use only the 2.6 from Apple that is actually working well with GDAL.
>> 
>> I did some search and found that tip on python bug report issue7107 on how to uninstall python from OS X:
>> 
>> http://bugs.python.org/issue7107
>> 
>> Regards,
>> 
>> Ivan

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

"Those people who most want to rule people are, ipso-facto, those least suited to do it."

- A rule of the universe, from the HitchHiker's Guide to the Galaxy




More information about the gdal-dev mailing list