gpt4 book ai didi

python - 升级到 Python 3.6 后启动时启动 cloud-init 失败

转载 作者:行者123 更新时间:2023-12-03 20:17:46 28 4
gpt4 key购买 nike

我在新的云服务器(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 上的一个已知错误(兼容性问题)。 (见 https://github.com/stefankoegl/python-json-patch/issues/56)。我必须通过 pip 升级软件包而不是 apt-get .这可以修复两个错误。

关于python - 升级到 Python 3.6 后启动时启动 cloud-init 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46328064/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com