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

Ivan Lucena ivan.lucena at pmldnet.com
Tue Sep 21 01:51:00 EDT 2010


William,

>  -------Original Message-------
>  From: William Kyngesburye <woklist at kyngchaos.com>
>  To: Ivan Lucena <ivan.lucena at pmldnet.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 21:53
>  
>  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

Looking back to my log, that command didn't get through, it returned "file already exist". 

My bad. I should have said "get rid of the PATH entries added by the python.org installer in your .profile" 

I understand that your following comments are based on my wrong statement but they are important to me anyway.

>  >
>  Ah, something must have deleted this file.  This exists on a clean OS X install.  And, more correctly, the files are 
more complicated:

I would guess that in a clean OS X Install /usr/bin/python is a symbolic link to:

/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6

Am I right?

I followed the instruction on issue7107 and now I have a "ghost" Python.framework at:

/Library/Frameworks/Python.framework/Versions/2.7

But that should not affect anything. Right? That is not the official Apple's Python installation. Correct me if I am 
wrong.

So now, when I type "python" the system is not going to find the "python" executable that existed over there but it 
will find the /usr/bin/python symbolic link instead. Is that a good thing or not? Am I missing something?

Note that the site-package is in another corner:

$ ls /Library/Python/2.6/site-packages/
GDAL-1.7.0-py2.6-macosx-10.6-universal.egg	easy-install.pth
README						numpy-1.5.0-py2.6-macosx-10.6-universal.egg

That seems to be shared by everybody.

>  
>  /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.

That is very interesting. I will certainly investigate more about it. I have just 4 days of OS X experience, BTW.

>  
>  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.

There are three versions of python on /System/Library/Frameworks/Python.framework/Versions:

$ ls /System/Library/Frameworks/Python.framework/Versions
2.3	2.5	2.6	Current

They all look health and in good shape so there is no reason for panic. That is what I am trying to convince myself. I 
will examine a fresh installation and compare. Just to make sure.

The key point to me was that the python.org distribution are not compatible with the building process of GDAL python 
wrapper using the gcc from XCode. Doesn't matter what options I run on ./configure.

I should have never installed python anyway. The one that comes with the system is good enough. I did not know 
that.

The solution is to restore the system as it was before the python.org installation. I could just remove/comment the 
entries on my .profile and I could also remove the Python.framework from the python.org installation. I did both.

Do you think that a solution like that would also work for Jeff?

My best regards,

Ivan

>  
>  > 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