Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

286
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda