简体   繁体   English

适用于 OSX Swift 项目的 PythonKit 突然找不到模块

[英]PythonKit for OSX Swift project suddenly not finding modules

I built a MacOS app using PythonKit to run some scripts and return the data.我使用 PythonKit 构建了一个 MacOS 应用程序来运行一些脚本并返回数据。 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.我已经验证文件的路径是正确的,并且在终端中运行 Python 脚本没有问题。

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: PythonKit 中抛出它的代码行:

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

My Python code in the file:我在文件中的 Python 代码:

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)

Ug, this was operator error, I was pointing to the file, not the directory containing the file.呃,这是操作员错误,我指向的是文件,而不是包含文件的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM