Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
How to import python modules and use python scripts in SwiftUI with PythonKit?
**the SwiftUI file** 
import SwiftUI
import PythonKit
let main = Python.import("main.py") 
Button(action:{
        main.func($symptoms as! PythonConvertible)
    }) {
        Image(systemName: "arrowtriangle.forward")
            .font(.largeTitle)

            .foregroundColor(.black)
            .position(x:200, y:-200)
    }


**main.py**
from pathlib import Path
from datetime import datetime
from collections import defaultdict


def func():
    try:
       from googlesearch import search
    except ImportError:
       print("No module named 'google' found, please install it")
  
...

Hi I'm relatively new to Swift and iOS app development and I've been trying to write an iOS app which uses a Python script to search google for a result, I've already installed the PythonKit in Xcode but I still can't use the function I defined in main.py, despite referencing it in the SwiftUI file. Every time the button is pressed, the xCode emulator just crashes and macOS returns a lengthy error message. Does anyone know how to do this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!