升级到Python 3.6后启动时无法启动cloud-init

2024-05-04

我在新的云服务器(Ubuntu 16.04)上安装了 Python 3.6,而不是默认的 3.5 版本。我重启服务器后发现执行失败cloud-init启动时出现以下错误syslog.

Sep 20 16:16:14 cloud-init[1310]: Traceback (most recent call last):
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/bin/cloud-init", line 9, in <module>
Sep 20 16:16:14 cloud-init[1310]:     load_entry_point('cloud-init==0.7.9', 'console_scripts', 'cloud-init')()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 570, in load_entry_point
Sep 20 16:16:14 cloud-init[1310]:     return get_distribution(dist).load_entry_point(group, name)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2751, in load_entry_point
Sep 20 16:16:14 cloud-init[1310]:     return ep.load()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2405, in load
Sep 20 16:16:14 cloud-init[1310]:     return self.resolve()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
Sep 20 16:16:14 cloud-init[1310]:     module = __import__(self.module_name, fromlist=['__name__'], level=0)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 27, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from cloudinit import stages
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 21, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from cloudinit.handlers import cloud_config as cc_part
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/handlers/cloud_config.py", line 11, in <module>
Sep 20 16:16:14 cloud-init[1310]:     import jsonpatch
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/jsonpatch.py", line 114, in <module>
Sep 20 16:16:14 cloud-init[1310]:     json.load = get_loadjson()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/jsonpatch.py", line 108, in get_loadjson
Sep 20 16:16:14 cloud-init[1310]:     argspec = inspect.getargspec(json.load)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3.6/inspect.py", line 1072, in getargspec
Sep 20 16:16:14 cloud-init[1310]:     raise ValueError("Function has keyword-only parameters or annotations"
Sep 20 16:16:14 cloud-init[1310]: ValueError: Function has keyword-only parameters or annotations, use getfullargspec() API which can support them
Sep 20 16:16:14 cloud-init[1310]: Error in sys.excepthook:
Sep 20 16:16:14 cloud-init[1310]: Traceback (most recent call last):
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
Sep 20 16:16:14 cloud-init[1310]:     from apport.fileutils import likely_packaged, get_recent_crashes
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from apport.report import Report
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
Sep 20 16:16:14 cloud-init[1310]:     import apport.fileutils
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from apport.packaging_impl import impl as packaging
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
Sep 20 16:16:14 cloud-init[1310]:     import apt
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
Sep 20 16:16:14 cloud-init[1310]:     import apt_pkg
Sep 20 16:16:14 cloud-init[1310]: ModuleNotFoundError: No module named 'apt_pkg'
Sep 20 16:16:14 cloud-init[1310]: Original exception was:
Sep 20 16:16:14 cloud-init[1310]: Traceback (most recent call last):
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/bin/cloud-init", line 9, in <module>
Sep 20 16:16:14 cloud-init[1310]:     load_entry_point('cloud-init==0.7.9', 'console_scripts', 'cloud-init')()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 570, in load_entry_point
Sep 20 16:16:14 cloud-init[1310]:     return get_distribution(dist).load_entry_point(group, name)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2751, in load_entry_point
Sep 20 16:16:14 cloud-init[1310]:     return ep.load()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2405, in load
Sep 20 16:16:14 cloud-init[1310]:     return self.resolve()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
Sep 20 16:16:14 cloud-init[1310]:     module = __import__(self.module_name, fromlist=['__name__'], level=0)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 27, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from cloudinit import stages
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 21, in <module>
Sep 20 16:16:14 cloud-init[1310]:     from cloudinit.handlers import cloud_config as cc_part
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/cloudinit/handlers/cloud_config.py", line 11, in <module>
Sep 20 16:16:14 cloud-init[1310]:     import jsonpatch
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/jsonpatch.py", line 114, in <module>
Sep 20 16:16:14 cloud-init[1310]:     json.load = get_loadjson()
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3/dist-packages/jsonpatch.py", line 108, in get_loadjson
Sep 20 16:16:14 cloud-init[1310]:     argspec = inspect.getargspec(json.load)
Sep 20 16:16:14 cloud-init[1310]:   File "/usr/lib/python3.6/inspect.py", line 1072, in getargspec
Sep 20 16:16:14 cloud-init[1310]:     raise ValueError("Function has keyword-only parameters or annotations"
Sep 20 16:16:14 cloud-init[1310]: ValueError: Function has keyword-only parameters or annotations, use getfullargspec() API which can support them
Sep 20 16:16:14 systemd[1]: Started MySQL Community Server.
Sep 20 16:16:14 systemd[1]: cloud-config.service: Main process exited, code=exited, status=1/FAILURE
Sep 20 16:16:14 systemd[1]: Failed to start Apply the settings specified in cloud-config.
Sep 20 16:16:14 systemd[1]: cloud-config.service: Unit entered failed state.
Sep 20 16:16:14 systemd[1]: cloud-config.service: Failed with result 'exit-code'.

显然有两个问题:

ModuleNotFoundError: No module named 'apt_pkg'

ValueError: Function has keyword-only parameters or annotations, use getfullargspec() API which can support them

所以我跑了apt-get install python3-apt,但该软件包已安装。然后我跑了apt-get install python3-jsonpatch,并且已经成功完成。不幸的是,问题并没有得到解决。


最后我通过升级解决了这个问题jsonpatch封装有pip.

$ pip3 install --upgrade jsonpatch

这是旧版本的一个已知错误(兼容性问题)jsonpatch (see https://github.com/stefankoegl/python-json-patch/issues/56 https://github.com/stefankoegl/python-json-patch/issues/56)。我必须通过以下方式升级软件包pip代替apt-get。这可以修复两个错误。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

升级到Python 3.6后启动时无法启动cloud-init 的相关文章

  • 安装了 32 位的 Python,显示为 64 位

    我需要运行 32 位版本的 Python 我认为这就是我在我的机器上运行的 因为这是我下载的安装程序 当我重新运行安装程序时 它会将当前安装的 Python 版本称为 Python 3 5 32 位 然而当我跑步时platform arch
  • 将html数据解析成python列表进行操作

    我正在尝试读取 html 网站并提取其数据 例如 我想查看公司过去 5 年的 EPS 每股收益 基本上 我可以读入它 并且可以使用 BeautifulSoup 或 html2text 创建一个巨大的文本块 然后我想搜索该文件 我一直在使用
  • 当变量取特定值时如何使 PyCharm 中断?

    我有一本大字典 其中一些元素偶尔会出现非法值 我想弄清楚非法值从何而来 PyCharm 应该不断监视我的字典的值 一旦它们中的任何一个取了非法值 它就应该中断并让我检查程序的状态 我知道我可以通过为我的字典创建一个 getter sette
  • 用枢轴点拟合曲线 Python

    我有下面的图 我想用 2 条线来拟合它 使用 python 我设法适应上半部分 def func x a b x np array x return a x b popt pcov curve fit func up x up y 我想用另
  • Python zmq SUB 套接字未接收 MQL5 Zmq PUB 套接字

    我正在尝试在 MQL5 中设置一个 PUB 套接字 并在 Python 中设置一个 SUB 套接字来接收消息 我在 MQL5 中有这个 include
  • 使用字典映射数据帧索引

    为什么不df index map dict 工作就像df column name map dict 这是尝试使用index map的一个小例子 import pandas as pd df pd DataFrame one A 10 B 2
  • 如何使用 Pandas、Numpy 加速 Python 中的嵌套 for 循环逻辑?

    我想检查一下表的字段是否TestProject包含了Client端传入的参数 嵌套for循环很丑陋 有什么高效简单的方法来实现吗 非常感谢您的任何建议 def test parameter a list parameter b list g
  • Python 2:SMTPServerDisconnected:连接意外关闭

    我在用 Python 发送电子邮件时遇到一个小问题 me my email address you recipient s email address me email protected cdn cgi l email protectio
  • 在 Sphinx 文档中*仅*显示文档字符串?

    Sphinx有一个功能叫做automethod从方法的文档字符串中提取文档并将其嵌入到文档中 但它不仅嵌入了文档字符串 还嵌入了方法签名 名称 参数 我如何嵌入only文档字符串 不包括方法签名 ref http www sphinx do
  • 加快网络抓取速度

    我正在使用一个非常简单的网络抓取工具抓取 23770 个网页scrapy 我对 scrapy 甚至 python 都很陌生 但设法编写了一个可以完成这项工作的蜘蛛 然而 它确实很慢 爬行 23770 个页面大约需要 28 小时 我看过scr
  • Jupyter Notebook 找不到 Python 模块

    不知道发生了什么 但每当我使用 ipython 氢 原子 或 jupyter 笔记本时都找不到任何已安装的模块 我知道我安装了 pandas 但笔记本说找不到 我应该补充一点 当我正常运行脚本时 python script py 它确实导入
  • 如何使用原始 SQL 查询实现搜索功能

    我正在创建一个由 CS50 的网络系列指导的应用程序 这要求我仅使用原始 SQL 查询而不是 ORM 我正在尝试创建一个搜索功能 用户可以在其中查找存储在数据库中的书籍列表 我希望他们能够查询 书籍 表中的 ISBN 标题 作者列 目前 它
  • 如何断言 Unittest 上的可迭代对象不为空?

    向服务提交查询后 我会收到一本字典或一个列表 我想确保它不为空 我使用Python 2 7 我很惊讶没有任何assertEmpty方法为unittest TestCase类实例 现有的替代方案看起来并不正确 self assertTrue
  • 如何在 MacBook Pro 上的 Docker 容器内运行 tkinter?

    我正在尝试运行一个使用以下命令的 python GUI 应用程序tkinter我的 MacBook Pro 上的 docker 容器内的模块 所以我安装了XQuartz https www xquartz org 并跟随本教程 https
  • Pandas 将多行列数据帧转换为单行多列数据帧

    我的数据框如下 code df Car measurements Before After amb temp 30 268212 26 627491 engine temp 41 812730 39 254255 engine eff 15
  • 如何解决 PDFBox 没有 unicode 映射错误?

    我有一个现有的 PDF 文件 我想使用 python 脚本将其转换为 Excel 文件 目前正在使用PDFBox 但是存在多个类似以下错误 org apache pdfbox pdmodel font PDType0Font toUnico
  • Python ImportError:无法导入名称 __init__.py

    我收到此错误 ImportError cannot import name life table from cdc life tables C Users tony OneDrive Documents Retirement retirem
  • 实现 XGboost 自定义目标函数

    我正在尝试使用 XGboost 实现自定义目标函数 在 R 中 但我也使用 python 所以有关 python 的任何反馈也很好 我创建了一个返回梯度和粗麻布的函数 它工作正常 但是当我尝试运行 xgb train 时它不起作用 然后 我
  • Django-tables2 列总计

    我正在尝试使用此总结列中的所有值文档 https github com bradleyayers django tables2 blob master docs pages column headers and footers rst 但页
  • 如何应用一个函数 n 次? [关闭]

    Closed 这个问题需要细节或清晰度 help closed questions 目前不接受答案 假设我有一个函数 它接受一个参数并返回相同类型的结果 def increment x return x 1 如何制作高阶函数repeat可以

随机推荐