Python错误类型:<class'AttributeError'>Args:(“'module'对象没有属性'Retry'”,)

2024-04-23 21:25:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我在两个环境中有相同的Python脚本。其中一个很好,但在另一个日志中我发现了这个错误:

15-May-2017 15:29:39  |  Type: <class 'AttributeError'>
15-May-2017 15:29:39  |  Args: ("'module' object has no attribute 'Retry'",)

我认为它来自以下几个方面:

^{pr2}$

不幸的是,这个错误没有告诉我太多,所以我真的不知道该怎么做。在

有人有什么建议吗?或者你能看到代码有什么问题吗?在

16-May-2017 07:33:23  |  -----------------------------------------------------------------------------------------
16-May-2017 07:33:23  |  Initialising get_usage
16-May-2017 07:33:23  |  -----------------------------------------------------------------------------------------
16-May-2017 07:33:23  |  net = testnet
16-May-2017 07:33:23  |  manager_url = https://xxx.xxx.xxx.xxx/manager/api/json/1.0/list.adm
16-May-2017 07:33:23  |  storage_endpoint = endpoint_url
16-May-2017 07:33:23  |  storage_bucket = bucket_url
16-May-2017 07:33:23  |  Calling https://xxx.xxx.xxx.xxx/manager/api/json/1.0/list.adm
16-May-2017 07:33:23  |  [GET] -> https://xxx.xxx.xxx.xxx/manager/api/json/1.0/list.adm
16-May-2017 07:33:23  |  Starting new HTTPS connection (1): xxx.xxx.xxx.xxx
16-May-2017 07:33:23  |  https://xxx.xxx.xxx.xxx:443 "GET /manager/api/json/1.0/list.adm HTTP/1.1" 200 1473
16-May-2017 07:33:23  |     |- OK
16-May-2017 07:33:23  |  Type: <class 'AttributeError'>
16-May-2017 07:33:23  |  Args: ("'module' object has no attribute 'Retry'",)
16-May-2017 07:33:23  |  -------------------------------------------------------------------------------
16-May-2017 07:33:23  |  Finished
16-May-2017 07:33:23  |  -------------------------------------------------------------------------------
16-May-2017 07:33:23  |  -------------------------------------------------------------------------------
16-May-2017 07:33:23  |  Uploading file /opt/billing/bin/get_usage/get-usage.debug
16-May-2017 07:33:23  |  -------------------------------------------------------------------------------
16-May-2017 07:33:23  |  Type: <class 'AttributeError'>
16-May-2017 07:33:23  |  Args: ("'module' object has no attribute 'Retry'",)

作为进一步的测试,如果我在Pyhon执行以下操作:

>>> import minio
>>> from minio import Minio
>>> Minio("url", "access_key", "secret_key", False)

我得到以下信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/minio/api.py", line 152, in __init__
    retries=urllib3.Retry(
AttributeError: 'module' object has no attribute 'Retry'

但如果我使用boto3:

>>> import boto3
>>> s3client = boto3.client('s3', endpoint_url='https://url',
        aws_access_key_id = 'access_key',
        aws_secret_access_key = 'secret_key')
    print(s3client.list_buckets())

我得到一个json响应。在

看起来一个包有效,另一个不行


Tags: keynohttpsapijsonurlobjectmanager
2条回答

这解决了问题:

sudo pip3 install  upgrade urllib3

我当时在:

^{pr2}$

我现在开始:

pip3 show urllib3
 -
Name: urllib3
Version: 1.21.1
Location: /usr/local/lib/python3.4/dist-packages
Requires: 

谢谢你的帮助。在

miniourllib3模块之间不匹配。要么urllib3在显示问题的计算机上已过时,要么您有一个浮动的urllib3.py文件,它不是实际的模块。在

相关问题 更多 >