views:

224

answers:

1

Is there a way to program using pure python in Xcode? I want something like the c++ command line utility except for python, I found a tutorial that did not work for me: (after playing around with which active architecture finally decided on i386) when trying to print "Hello, World!" I get the following error "Data Formatters temporarily unavailable, will re-try after a 'continue'. (Cannot call into the loader at present, it is locked.)" (Using an intel Mac OS 10.6.4 and Xcode 3.2.3)

Here is how I followed the steps:
1) Opened Xcode went to File -> New Project
2) Selected from 'Other', 'Empty Project'
3) Named it 'PyProject' in a local directory on my computer
4) Went to File -> New File
5) From 'Pure Python' I selected 'Python tool', named it main.py then clicked finish
6) Added print ('Hello, World!') to the file, and saved the file
7) Went to Project -> New Custom Executable
8) Named it PyExecutable, gave it path" /Library/Frameworks/Python.framework/Versions/2.6/bin/python" and added it to project PyProject, then clicked Finish
9) Double-clicked PyExecutable in PyProject window
10) Went to Arguments and added the path of my main.py file "/Users/jordan/PyProject/main.py"
11) Switched Active Architecture from the pull down menu at the top of the PyProject window to i386 (Now is in Debug, No Active Target, PyExecutable Is Active Executable and Architecture is i386)(If I don't switch the architecture and leave it on default x86_64 I get this error as a pop-up "The active architecture x86_64 is not present in the executable 'PyExecutable' which contains ppc/i386")
12) Clicked Run -> Run and then I get the error listed above in the console

Before anyone suggests it: I know Xcode is not the best option for pure python please do not suggest that I use another text editor.

Edit: details of what was not working when following the tutorial

Edit: my system details were added, and the steps I followed to get the error

Update: I wrapped the path of main.py in double quotes "" and now when I press continue after the error the console prints hello world, but I get the same error originally.

A: 

/Library/Frameworks/Python.framework/Versions/2.6/bin/python is typically the path to the python.org installer Python (or possibly other non-Apple Python) which, indeed, includes only 32-bit architectures (ppc and i386). It also is built using the OS X 10.4u SDK (an optional install with Xcode on 10.6). The Apple-supplied Python 2.6 in 10.6 is built using a 10.6 SDK and includes 32-bit and 64-bit archs (i386, x86_64, and ppc for compatibility).

$ /usr/local/bin/python2.6 -c 'import sys;print(sys.executable)'  # python.org Python
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
$ /usr/bin/python2.6 -c 'import sys;print(sys.executable)'  # Apple-supplied Python
/usr/bin/python2.6

Decide which Python you want to use and change your Xcode project accordingly.

Ned Deily