PythonKit for OSX Swift project suddenly not finding modules

606 Views Asked by At

I built a MacOS app using PythonKit to run some scripts and return the data. I had it running with no issues the other day but now it crashes when trying to load the script file. I've verfied the path to the file is correct and have run the Python script in Terminal with no issues.

Here's the error message:

Fatal error: 'try!' expression unexpectedly raised an error: Python exception: No module named 'helloswift': file PythonKit/Python.swift, line 674
2021-04-09 10:01:55.441796-0400 TechCommToolKit[10754:2952424] Fatal error: 'try!' expression unexpectedly raised an error: Python exception: No module named 'helloswift': file PythonKit/Python.swift, line 674

The line of code in PythonKit throwing it:

public func `import`(_ name: String) -> PythonObject { return try! attemptImport(name) }

My Python code in the file:

import requests
import json
import sys

def getConfluenceData(strEndPoint):

    s = requests.Session()

    response = s.post('https://wiki.xxxx.com/dologin.action', data={'os_username': 'app_wiki_api2', 'os_password': 'xxxxxxxxxxxxxxxx'})
    response = s.get(strEndPoint)

    json_formatted_str = json.dumps(response.json(), indent=4)

    return(json_formatted_str)
1

There are 1 best solutions below

0
On

Ug, this was operator error, I was pointing to the file, not the directory containing the file.