gpt4 book ai didi

python docker 抛出错误 : AttributeError: module 'six' has no attribute 'PY34'

转载 作者:行者123 更新时间:2023-12-02 18:18:45 29 4
gpt4 key购买 nike

我正在编写一个脚本,它将构建 docker 镜像,然后将镜像推送到 ECR。我当前的 python 版本是

>python --version
Python 3.8.0

因此,出于某种原因,在本地运行 python 时的第一行,我遇到了以下错误。这意味着,它还没有构建推送到 ECR 的镜像。

导入 docker --> 抛出以下错误

Traceback (most recent call last):
File "genericECR.py", line 1, in <module>
import docker
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\docker\__init__.py", line 2, in <module>
from .api import APIClient
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\docker\api\__init__.py", line 2, in <module>
from .client import APIClient
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\docker\api\client.py", line 8, in <module>
import websocket
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websocket\__init__.py", line 23, in <module>
from ._app import WebSocketApp
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websocket\_app.py", line 36, in <module>
from ._core import WebSocket, getdefaulttimeout
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websocket\_core.py", line 34, in <module>
from ._handshake import *
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\websocket\_handshake.py", line 40, in <module>
if six.PY34:
AttributeError: module 'six' has no attribute 'PY34'

已经安装了六个

Requirement already satisfied: six in c:\users\appdata\local\programs\python\python38-32\lib\site-packages (1.6.1)

它似乎适用于 python 34,所以对于 python 38,我该如何解决这个问题?

最佳答案

很可能是 6 版本不够高,参见https://github.com/docker/docker-py/issues/2294

首先查看六个版本:

import six
print(six.__version__)

如果六个版本不>=1.0.0,则在命令行上升级六个

python -m pip install -U six

使用最新的pip,您应该看到以下内容:

>>> import six
>>> six.__version__
'1.13.0'
>>> six.PY34
True

关于python docker 抛出错误 : AttributeError: module 'six' has no attribute 'PY34' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59372496/

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