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.

Richard JP Le Guen
  • 26,771
  • 7
  • 80
  • 113
Jordan
  • 4,584
  • 4
  • 23
  • 39
  • So what happens if you follow the excellent, detailed instructions at the site you pointed to? Hard to tell you what to fix if you don't tell us what's wrong! Please edit your Q to supply detailed info instead of just "did not work for me, but seemed close"!-) – Alex Martelli Aug 17 '10 at 02:30
  • @Alex: Sorry that slipped my mind I updated the question, and thanks for the polite tone (that was me being sincere not sarcastic, at times people can be really tough on SO) – Jordan Aug 17 '10 at 02:36
  • @Jordan, can't reproduce your error on my Mac (intel, osx 10.5, Xcode 3.1.4) -- following the steps on the site shows me "Hello world" (the coded I added being of course `print('Hello world')`!-) on the Debugger Console. You should probably edit your Q again to specify your platform's details, and what steps exactly you've followed (that tutorial is from 2005 so there are likely to be miniscule differences in the UI it assumes for Xcode -- I just winged it on those guidelines, having never used Xcode this way before;-). – Alex Martelli Aug 17 '10 at 04:37
  • @Alex: I updated the question, perhaps you could tell me how your steps differed from mine. – Jordan Aug 17 '10 at 12:21
  • 1
    @Jordan, sub (5) I picked "Python module" instead of "Python tool" (sorry, I don't know what the difference it, either;-). If it's not that, it must be something about OSX 10.6 or XCode 3.2 -- as I mentioned, what I have are 10.5 and 3.1 respectively (yeah, I'll get around to upgrading any time now -- I've owned a 10.6 family license pack for almost a year now, after all...;-). – Alex Martelli Aug 17 '10 at 14:58
  • @Alex: I tried changing to python module, no such luck – Jordan Aug 17 '10 at 18:28
  • @Jordan, I have no other ideas (I didn't have to do step 11 since it was already i386 on mine, but I doubt that's it). – Alex Martelli Aug 17 '10 at 23:29
  • Take a look at my question and answer with step by step instructions. I keep updating as needed. http://stackoverflow.com/questions/5276967/python-in-xcode-4 – Tyler Crompton Nov 09 '11 at 09:41

1 Answers1

1

/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
  • 78,314
  • 15
  • 120
  • 148