xcode如何编译python

1、找到Python位置:

终端输入:which python

获取python的安装位置,一般为/usr/bin/python。获取到这个路径方便使用它来搭建python的编译环境。

2、在Xcode中创建python程序

打开Xcode,新建工程(Shift+Command+N),选择Cross-platform->Ohter->External Build System,继续下一步。

在Build Tool中粘贴刚刚找到的python路径,eg:/usr/bin/python,点击Next:

3、设置Edit Scheme

创建好项目之后,在左上角的项目图表上点击一下,选择Edit Scheme

第一个选项Info中的Executable选择python的路径,eg:/usr/bin/python

第二个选项Arguments里,在第一个Arguments passed on launch里,新建一个你即将新建的.py文件,eg:main.py

第三个选项Option里,勾选Working Directory并选择到Xcode Project所在的文件夹,也就是你的.py文件存放的文件夹,最后选择确定。

4、Build and Run

在项目中新建文件(Command+N),选择macOS->Other->Empty,命名为刚刚在Scheme里添加的文件名,eg:mian.py

现在编写代码,并点击Run, 就可以实现python程序在Xcode下的编译和运行了。

相关推荐
IvanCodes9 小时前
Python 数据处理(十三):JSON、CSV 与数据序列化
开发语言·python
Patrick在香港10 小时前
Claude 工具调用返回空:8 次失败里只有 1 次状态码不对,其余全带 200
爬虫·python·api·claude·香港
Web3&Basketball10 小时前
CRM Agent 后训练实战:3 倍更少错误
python·架构·大模型·agent·推理
AIFQuant11 小时前
ETF行情API接入踩坑记:从报错到跑通的七个问题
python·金融·区块链·etf·基金
GPU实战笔记13 小时前
云端 Python 开发:JupyterLab 还是 VS Code Remote-SSH?
python·vs code·jupyterlab·remote-ssh·远程开发
狗狗狗狗狗乐啊13 小时前
搭一个 AI 对话工作台 AChat:从 0 到可用的完整记录(一)
python·react.js·ai编程
白猫不黑14 小时前
Python实现简易Web弱口令爆破与防护方案
python·web安全·计算机·网络安全·黑客·信息安全·渗透测试
kuuailetianzi14 小时前
Python初识:定位、优势与发展历程
python
guoran_shini15 小时前
LLM微调-训练垂类问答模型
python·lora·sft
basketball61615 小时前
Python FastAPI 介绍以及常用方法
python·fastapi·vllm·ai infra