需要先熟悉几个指令:
brew install python ‘or’ Xcode runing Python3 安装
which python ‘or’ which python3 获取路径
python -V ‘or’ python3 -V 获取版本
brew search python 全局查找python
sudo rm -rf /Library../python 移除
安装python
1.检查macOS环境下的python环境
python -V ‘or’ python3 -V
output: Python 3.8.9
2.如果不存在或需要更新可以用
brew install python ‘or’ Xcode runing Python3
output:/usr/bin/python3
创建项目
[1] new project target 【External Build System】
[2] Build tool 【python path】
[3.1] 选中Info
(1)取消选中 DEbug executable (2)选中指定 python exec
[3.2] 选中Arguments
执行 Arguments Passed On Launch 增加python文件
[3.3] 选中Options
执行 Working Directory 路径
[4]新建文件 Empty
[5]运行项目
疑难排查
可能遇到的问题: [Errno 2] No such file or directory
上图3.3这一步,1.检查是否勾选,2.检查路径是否正确
可能遇到的问题:[Errno 1] Operation not permitted
需要添加python3 并开启访问权限
可能遇到的问题: 上图3.1搜索到指定python,但无法添加
在要使用的python上层文件夹目录下,执行命令创建一个同步链接,例 ln python3.10.8 python318,就可以添加了