title: How to import python modules and use python scripts in SwiftUI with PythonKit?
body: <pre><code>**the SwiftUI file** 
  import SwiftUI
  import PythonKit
  let main = Python.import(&quot;main.py&quot;) 
  Button(action:{
          main.func($symptoms as! PythonConvertible)
      }) {
          Image(systemName: &quot;arrowtriangle.forward&quot;)
              .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(&quot;No module named 'google' found, please install it&quot;)
    
  ...
  </code></pre>
  <p>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?</p>