0

我想尝试使用 Python 开发 Cocoa 应用程序。我是 Mac 新手,我需要一些帮助来了解它是如何工作的。

首先我发现我需要安装py2app和py2objc。我使用了这里记录的 easy_install 。安装工具有一些错误,但最终安装了 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?不幸的是,我还没有找到我之前发布的错误解决方案。
  2. 据我了解有两种蟒蛇。一个我安装到 Applications 文件夹(IDLE、启动器)中,另一个是 OS 提供的当前 Python 版本。你能描述一下区别吗?
  3. 如何选择 Mac OS 使用的当前 Python 版本?/Library/Frameworks/Python.framework 中的当前文件夹是什么?

可能看起来很混乱,但这是我的第一步!:) 谢谢

4

1 回答 1

1
  1. 对此无法给出肯定的答案。见评论。
  2. 您可以在您的机器上安装多个版本的 python(OSX 包括您已经提到的默认版本)。在应用程序文件夹中有一些应用程序可以打开一个交互式解释器,您可以在其中输入 python 命令,例如 IDLE。这些应用程序使用您已安装的 python 版本之一。这让我们
  3. python_select是你想要的命令。例如python_select -l,列出您已安装的所有 python 版本并python_select python27选择您自己的 2.7 版本。Current文件夹链接到当前选择的版本python_select
于 2011-03-20T11:52:26.667 回答