PythonKit 错误“未找到 Python 库。使用 Python 库的路径设置 PYTHON_LIBRARY 环境变量”

Fer*_*ada 6 python xcode ios spacy swift-pythonkit

我使用 PythonKit 和 XCode 从 swift 代码调用 spaCy API。从 Home-brew 安装了 PythonKit,将其导入到我的项目中并且构建得很好;但是,在运行时我收到错误:

Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library.
Run Code Online (Sandbox Code Playgroud)

所以我编译了PythonTools(在PythonKit目录中,运行swift package generate-xcodeproj并打开PythonKit.xcodeproj文件)来查看它会找到Python库的哪些路径:

/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python37.zip
/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7
/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
/Users/fernandabrum/Library/Python/3.7/lib/python/site-packages
/usr/local/lib/python3.7/site-packages
Run Code Online (Sandbox Code Playgroud)

如果我的系统中存在 Python 库,为什么会出现“未找到 Python 库”的错误?我究竟做错了什么?

OBS.:我还尝试设置 PYTHON_LIBRARYexport PYTHON_LIBRARY=和上面找到的路径,但不成功。

提前致谢!

fro*_*cjn 1

在签名和功能下的“强化运行时”中:选中“禁用库验证”请参阅此处的答案:我无法使用 PythonKit 在 Xcode 11 中导入 Python 模块