Xcode中的纯Python [英] Pure Python in Xcode

查看:90
本文介绍了Xcode中的纯Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在Xcode中使用纯python进行编程?我想要类似c ++命令行实用程序的工具(除了python),我发现了时,出现以下错误数据格式化程序暂时不可用,将重试继续"之后.(目前无法调用加载程序,它已被锁定.)"(使用Intel Mac OS 10.6.4和Xcode 3.2.3)

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)

这是我遵循的步骤:
1)打开Xcode进入File-> New Project
2)从其他",空项目"中选择
3)在我计算机的本地目录中将其命名为"PyProject"
4)转到文件->新文件
5)从纯Python"中选择"Python工具",将其命名为main.py,然后单击完成.
6)在文件中添加print ('Hello, World!'),并保存文件
7)进入项目->新的自定义可执行文件
8)将其命名为PyExecutable,为其指定路径"/Library/Frameworks/Python.framework/Versions/2.6/bin/python",并将其添加到项目PyProject中,然后单击Finish
9)在PyProject窗口中双击PyExecutable
10)进入参数并添加了main.py文件"/Users/jordan/PyProject/main.py"的路径
11)将活动架构从PyProject窗口顶部的下拉菜单切换到i386(现在处于调试状态,没有活动目标,PyExecutable处于活动可执行状态,而架构是i386)(如果我不切换架构并保留它在默认x86_64上,我以弹出窗口形式收到此错误活动架构x86_64在包含ppc/i386的可执行文件'PyExecutable'中不存在")
12)单击运行->运行,然后在控制台中收到上面列出的错误

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

在有人建议之前:我知道Xcode并不是纯python的最佳选择,请不要建议我使用其他文本编辑器.

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.

按照本教程操作时不起作用的详细信息

details of what was not working when following the tutorial

添加了我的系统详细信息,以及为得到错误而执行的步骤

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

更新:我将main.py的路径括在双引号""中,现在在错误后按继续"时,控制台会打印hello world,但最初会出现相同的错误.

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.

推荐答案

/Library/Frameworks/Python.framework/Versions/2.6/bin/python通常是python.org安装程序Python(或可能的其他非Apple Python)的路径,该安装程序实际上仅包含32位架构(ppci386).它还使用OS X 10.4u SDK(在10.6上带有Xcode的可选安装)构建.苹果公司在10.6中提供的Python 2.6是使用10.6 SDK构建的,并包括32位和64位拱门(出于兼容性考虑,i386x86_64ppc).

/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

确定要使用的Python,并相应地更改Xcode项目.

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

这篇关于Xcode中的纯Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆