gpt4 book ai didi

python - 属性错误 : module 'importlib' has no attribute 'util'

转载 作者:行者123 更新时间:2023-12-03 10:06:27 24 4
gpt4 key购买 nike

我刚刚从 Fedora 32 升级到 Fedora 33(Python 3.9 附带)。从此gcloud命令停止工作:

[guy@Gandalf32 ~]$ gcloud 
Error processing line 3 of /home/guy/.local/lib/python3.9/site-packages/XStatic-1.0.2-py3.9-nspkg.pth:

Traceback (most recent call last):
File "/usr/lib64/python3.9/site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 562, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'

Remainder of file ignored
Traceback (most recent call last):
File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
main()
File "/usr/lib64/google-cloud-sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/usr/lib64/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/usr/lib64/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/usr/lib64/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/usr/lib64/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/usr/lib64/python3.9/re.py", line 124, in <module>
import enum
File "/usr/lib64/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

最佳答案

GCP 支持更新
GCP support mentioned那个新版本318.0.0发布于 2020.11.10应该支持python 3.9
我将我的 gcloud sdk 更新为 318.0.0现在看起来支持 python 3.9.0。
要解决此问题,请运行gcloud components updateFedora 33 包含 python 2.7 并强制 GCloud SDK 使用它,请设置此环境变量

export CLOUDSDK_PYTHON=python2
您可以将此导出命令添加到您的 ~/.bash_profilePython 3.9 很新,预计 Gcloud SDK 不支持 3.9,它被编写为兼容 2.7.x & 3.6 - 3.8(3.8 会导致一些兼容性问题,我建议使用 3.7)
作为解决方法,将 Python 3.8 或 3.7(这些版本适用于 Gcloud 和大多数 linux 发行版)作为系统范围的解释器并尝试使用 gcloud 命令。

关于python - 属性错误 : module 'importlib' has no attribute 'util' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64010263/

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