我正在Xcode 11.4.1中开发一个iOS单视图应用程序 我在文件中添加了pythonkit框架>;Swift套餐>;添加包依赖性并添加git repo:https://github.com/pvieito/PythonKit.git
当我尝试导入pythonkit并在“ViewController.swift”中使用它时:
import UIKit
import PythonKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
myfunc()
// Do any additional setup after loading the view.
}
func myfunc(){
print("Hello...")
print(Python.version)
}
}
它给出了以下错误:
Fatal error: Python library not found. Set the PYTHON_LIBRARY environment variable with the
path to a Python library.: file
/Users/sayansen/Library/Developer/Xcode/DerivedData/TestApp1-cjzcpyjbchjbrlbzuhbvpjlsttfp/SourcePackages/checkouts/PythonKit/PythonKit/PythonLibrary.swift,
line 40
2020-05-06 17:42:27.320360+0530 TestApp1[35313:1897321] Fatal error: Python library not found. Set the PYTHON_LIBRARY environment variable with the path to a Python library.: file /Users/sayansen/Library/Developer/Xcode/DerivedData/TestApp1-cjzcpyjbchjbrlbzuhbvpjlsttfp/SourcePackages/checkouts/PythonKit/PythonKit/PythonLibrary.swift, line 40
(lldb)
我试图在xcode中为MacOS构建一个“命令行工具”。在那个项目中,我添加了上面提到的pythonkit框架,它工作起来很有魅力! 为什么这个错误发生在iOS应用程序而不是Mac OS应用程序上
注意:我已经试过了this simmilar post 请帮帮我
我用PythonKit来支持iOShttps://github.com/kewlbear/PythonKit此Swift包将通过依赖关系将Python嵌入到您的应用程序中
我们可以如下安装
PythonKit
。请从项目文件夹中创建macOS
应用程序,并按照以下步骤操作Pythonkit也适用于macOS、Linux和Windows。它的要求没有具体说明iOS。iOS没有任何python解释器,因此无法识别“python”。 希望这有帮助
相关问题 更多 >
编程相关推荐