【问题标题】:Understanding concepts of Python installation on Mac OS for Cocoa development了解在 Mac OS 上安装 Python 以进行 Cocoa 开发的概念
【发布时间】:2011-03-20 10:32:54
【问题描述】:

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

首先我发现我需要安装py2app和py2objc。我使用了here 记录的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. 据我了解 有两种蟒蛇。一个我 安装到应用程序文件夹 (IDLE,启动器),另一个是 当前提供的 Python 版本 操作系统。你能描述一下吗 区别?
  3. 如何选择 当前使用的 Python 版本 苹果系统?什么是电流 文件夹在 /Library/Frameworks/Python.framework?

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

【问题讨论】:

  • 似乎找不到某些包含文件。这意味着包含目录设置错误。请参阅有关如何指定包含目录的问题:stackoverflow.com/questions/4753127 The missing include files live in /usr/include

标签: python osx-snow-leopard cocoa-bindings py2app


【解决方案1】:
  1. 无法给出明确的答案。见评论。
  2. 您可以在您的机器上安装多个版本的 python(OSX 包括您已经提到的默认版本)。在应用程序文件夹中有一些应用程序可以打开一个交互式解释器,您可以在其中输入 python 命令,例如 IDLE。这些应用程序使用您已安装的 python 版本之一。这将我们带到
  3. python_select 是您想要的命令。例如python_select -l 列出您已安装的所有 python 版本,python_select python27 选择您自己的 2.7 版本。 Current 文件夹链接到当前通过 python_select 选择的版本

【讨论】:

  • 这很奇怪!我收到:“bash:python_select:找不到命令”
  • 我安装了 Macports 和 python_select 包。我还重新安装了 XCode,因为我需要 Macports 的“Unix 开发工具”。我认为它也改变了python配置,因为'python_select -l'输出我只有一个版本的Python:2.6。我需要时间弄清楚:))
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-17
  • 2015-08-05
  • 1970-01-01
  • 2014-01-09
相关资源
最近更新 更多