开发者

Understanding concepts of Python installation on Mac OS for Cocoa development

开发者 https://www.devze.com 2023-02-18 09:15 出处:网络
I want to try to develop Cocoa application using Python. I\'m new to Mac and I need some help to understand how it works.

I want to try to develop Cocoa application using Python. I'm new to Mac and I need some help to understand how it works.

First of all I found that I need to install py2app and py2objc. I used easy_install as documented here. There were a few errors with setup tools but eventually py2app was installed. Then I launch "easy_install pyobjc==2.2" and it ended with many errors:

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
   开发者_Go百科 /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

My questions:

  1. What I need to do to install py2objc? Unfortunately, I haven't found a solution for errors, which I posted previously.
  2. As I understand there are two kinds of python. One I installed into Applications folder (IDLE, launcher), another is the current Python version supplied with OS. Can you describe the difference?
  3. How can I select the current version of Python used by Mac OS? And what is the Current folder in /Library/Frameworks/Python.framework?

Probably it looks confusing, but this is my first steps! :) Thank you


  1. Cannot give a definitive answer to that. See comment.
  2. You can install multiple versions of python on your machine (OSX includes a defualt one as you already mentioned). In the applications folder there are some apps to open an interactive interpreter in which you can enter python commands, such as IDLE. These applications use one of the python versions you've got installed. Which brings us to
  3. python_select is the command you want. e.g. python_select -l to list all the python versions you've got installed and python_select python27 to select your own 2.7 version. The Current folder links to the version currently selected via python_select
0

精彩评论

暂无评论...
验证码 换一张
取 消