[Pythonmac-SIG] Where is Python.h on OS X?

Glenn Andreas gandreas at delver.com
Sun Jul 11 17:27:19 CEST 2004


At 1:48 PM +0900 7/11/04, Jim Tittsler wrote:
>On Sun, Jul 11, 2004 at 12:31:13AM -0400, gohaku wrote:
>>  I am trying to compile the following:
>>
>>  // Don't forget to import "pythonXX.lib"!
>>  #include <Python.h>
>[...]
>>  I looked in /usr/include and could not find any such file.
>
>For 10.3:
>/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3/
>

It's a bit more subtle than that (especially when using XCode with 
the various OS SDK's installed).

Normally, from XCode, you can just "add framework", select Python (in 
/System/Library/Frameworks) and then do #include <Python/Python.h> 
and everything will work.  That's the easy answer.

...unless you try to target the 10.2.7  SDK (to try to build an app 
that works under 10.2.7 and would use a user-installed 
/Library/Frameworks/Python.framework) at which point it won't work... 
Turns out that XCode actually looks in 
/Developer/SDKs/MacOSX(whatever).sdk/System/Library/Frameworks, and 
there is no 
/Developer/SDKs/MacOSX10.2.7.sdk/System/Library/Frameworks/Python.Framework 
so even though you've added Python.framework (and can even see 
Python.h in xcode) it won't find it when building (and you have to 
manually add an include path, and you can't use the framework style 
include).


-- 
Glenn Andreas                      gandreas at gandreas.com 
mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know


More information about the Pythonmac-SIG mailing list