Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda