我正在使用带有XCode的PythonKit从快速代码中调用spaCy API。从Home-brew安装PythonKit,将其导入我的项目中,并且构建良好;但是,在运行时出现错误:
Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library.
所以我编译了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
如果我的系统中有Python库,为什么会出现未找到Python库的错误?我究竟做错了什么?
OBS.:
我还尝试使用export PYTHON_LIBRARY=
和上面找到的路径设置PYTHON_LIBRARY,但未成功。
谢谢!
答案 0 :(得分:0)
我有同样的问题。我尝试使用PythonLibrary.useVersion(3)
并得到与您相同的错误。
答案 1 :(得分:0)
在“强化运行时”的“签名和功能”下:选中“禁用库验证” 在此处查看答案:I can't import Python modules in Xcode 11 using PythonKit
答案 2 :(得分:0)
看起来python库还不支持iOS。它在 OS X 上运行良好。