python - 用于 OSX Swift 项目的 PythonKit 突然找不到模块
问题描述
我使用 PythonKit 构建了一个 MacOS 应用程序来运行一些脚本并返回数据。前几天我让它运行没有问题,但现在尝试加载脚本文件时它崩溃了。我已经验证文件的路径是正确的,并且在终端中运行 Python 脚本没有任何问题。
这是错误消息:
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
PythonKit 中抛出它的代码行:
public func `import`(_ name: String) -> PythonObject { return try! attemptImport(name) }
我在文件中的 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)
解决方案
呃,这是操作员错误,我指向的是文件,而不是包含文件的目录。
推荐阅读
- javascript - 更改克隆的 DOM 元素时 JS/jQuery 事件/数据丢失
- amazon-web-services - 使用 WAF 阻止垃圾邮件攻击
- html - HTML/CSS:获取
- react-native - React-Native 动画有一个小的停顿
- powershell - Powershell 中的 If/Else 帮助
- javascript - 在循环中将元素推入数组中,当我不推一个元素时,其余所有元素都显示为“未定义”
- jenkins - Jenkins 的 Subversion 提交后挂钩
- sql - 如何检查两个单独的数据库是否具有相同的表/查询/等?
- sql - 在 MDX 中选择 * 和 TOP()
- sql - ORA-01841: (完整) 年份必须介于 -4713 和 +9999 之间,并且不是 0 SQL 加载程序和 TOAD 问题