I'm trying to run some python code from Xcode but wasn't sure why it can't find the module. All the tutorial I found only shows importing the simple .py file that contains function only no import on the top. I'm using python3. TIA
import SwiftUI
import PythonKit
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.onAppear() {
runPython()
}
.padding()
}
func runPython() {
let sys = Python.import("sys")
sys.path.append(Config.Path.basePath)
let test = Python.import("example")
let response = test.hello()
print(response)
}
}
example.py
import pandas
def hello():
return "Hello Python"
Error:
PythonKit/Python.swift:706: Fatal error: 'try!' expression unexpectedly raised an error: Python exception: No module named 'pandas'