python - PythonKit 错误“找不到 Python 库。使用 Python 库的路径设置 PYTHON_LIBRARY 环境变量”
问题描述
我正在使用带有 XCode 的 PythonKit 从 swift 代码中调用 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,但没有成功。
提前致谢!
解决方案
在 Signing and Capabilities 下的“Hardened Runtime”中:选中“Disable Library Validation” 在此处查看答案:I can't import Python modules in Xcode 11 using PythonKit
推荐阅读
- c# - 在 C# Winforms 应用程序中键入时如何搜索 SQL Server 数据库?
- amazon-web-services - 为导入的 Kinesis 流获取 ARN
- go - 错误; 不能在 appendgo 中使用 imageName(类型 ImageName)作为类型 dao.ImageName
- python - 函数的副作用
- ruby-on-rails - 带有魔法宝石的多个模型
- angular - 在 dist 文件夹中构建 ng 后应该有多少个文件
- c# - 在 WPF 应用程序中的画布上仅呈现特定的几何图形数据
- webview - 是否可以在浏览器堆栈设备中使用 appium 运行 webview 自动化脚本
- java - 有没有办法在 morphia 中编写否定查询( ex nand , nor , not )
- elasticsearch - 如何使用 Painless 拒绝弹性搜索索引结果中的 json 数据类型列中的值?