2011-03-20 26 views
0

我想嘗試使用Python開發Cocoa應用程序。我是Mac新手,需要一些幫助來了解它的工作原理。理解Cocoa開發在Mac OS上安裝Python的概念

首先我發現我需要安裝py2app和py2objc。我使用easy_install作爲記錄here。安裝工具出現了一些錯誤,但最終安裝了py2app。然後,我推出 「easy_install pyobjc==2.2」,並與許多錯誤結束:

Processing pyobjc-2.2-py2.7.egg 
    ... 
Running pyobjc-framework-SystemConfiguration-2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ipMzFU/pyobjc-framework-SystemConfiguration-2.2/egg-dist-tmp-odfVol 
    In file included from Modules/_manual.m:1: 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:19:20: error: limits.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:22:2: error: #error "Something's broken. UCHAR_MAX should be defined in limits.h." 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:26:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type." 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:19: error: stdio.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:35:5: error: #error "Python.h requires that stdio.h define NULL." 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:20: error: string.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:40:19: error: errno.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:42:20: error: stdlib.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:44:20: error: unistd.h: No such file or directory 
    /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:56:20: error: assert.h: No such file or directory 
... 
etc 

我的問題:

  1. 我需要做安裝 py2objc什麼?不幸的是,我沒有找到一個解決錯誤的方法,我之前發佈了 。按照我的理解, 有兩種python。一個我 安裝到應用程序文件夾 (IDLE,啓動器),另一個是 當前Python版本與 OS提供。你能描述一下 的區別嗎?
  2. 如何選擇 Mac OS使用的Python的當前版本 ? /Library/Frameworks/Python.framework中的Current 文件夾是什麼?

大概看起來很混亂,但這是我的第一步! :) 謝謝

+0

看起來像一些包含文件無法找到。這意味着include-dir設置錯誤。看到這個問題如何指定包括目錄:h​​ttp://stackoverflow.com/questions/4753127 丟失的包含文件居住'/ usr/include' – 2011-03-20 11:41:18

回答

1
  1. 不能給出明確的答案。見評論。
  2. 您可以在您的計算機上安裝多個版本的Python(OSX包含一個您已經提到的未定義版本)。在應用程序文件夾中有一些應用程序可以打開交互式解釋器,您可以在其中輸入Python命令,如IDLE。這些應用程序使用您已安裝的其中一個python版本。這將我們帶到
  3. python_select是你想要的命令。例如python_select -l列出您安裝的所有python版本,並且python_select python27選擇您自己的2.7版本。 Current文件夾鏈接到當前通過選擇的版本python_select
+0

這很奇怪!我收到:「bash:python_select:command not found」 – 2011-03-20 19:53:08

+0

我安裝了Macports和python_select軟件包。我還重新安裝了XCode,因爲我需要Macports的「Unix開發工具」。我認爲它也改變了python配置,因爲'python_select -l'輸出我只有一個版本的Python:2.6。我需要一段時間弄清楚:)) – 2011-03-20 21:14:32