一、问题描述

在使用 Xcode 15.4 在 macOS 14.5 上尝试开发 Adobe Illustrator Plugin 时,在编译 Adobe Illustrator 2023 SDK 的 sample 过程中出现错误:

/Users/aidy/Workspace/Adobe Illustrator 2023 SDK/samplecode/StrokeFilter/build/StrokeFilter.build/Default/StrokeFilter.build/Script-FDD9160721AC093D0018B958.sh: line 2: python: command not found
Command PhaseScriptExecution failed with a nonzero exit code

查看 Script-FDD9160721AC093D0018B958.sh 文件内容为:

#!/bin/sh
python ../../tools/pipl/create_pipl.py -input '[{"name":"StrokeFilter","entry_point" : "PluginMain"}]'

二、尝试过程

首先怀疑是没有安装 xcode command line tool,但确认已经安装过了。 接着考虑可能是没有安装 Python。通过 brew install python 安装了 Python3,但 Xcode 中仍然提示python: command not found。 从 Adobe Community 搜索得知这里需要 Python2,于是使用 pyenv 安装了 Python2,并设置 pyenv global 2.7.18。在 Terminal 中执行 python -V 输出是 Python 2.7.18,然而 Xcode build 依旧报错。 尝试了 sudo ln /Users/<user>/.pyenv/shims/python /Library/Developer/CommandLineTools/usr/bin/python,但没有作用。

三、最终解决办法

通过 sudo ln /Users/<user>/.pyenv/shims/python /usr/local/bin/python 设置 /usr/local/binlink,解决了问题。