【问题标题】:aiobotocore - ImportError: cannot import name 'InvalidIMDSEndpointError'aiobotocore - ImportError:无法导入名称“InvalidIMDSEndpointError”
【发布时间】:2021-04-17 16:16:26
【问题描述】:

下面的代码引发了一个导入异常

import s3fs
fs = s3fs.S3FileSystem(anon=False)

例外

Traceback (most recent call last):
  File "issue.py", line 1, in <module>
    import s3fs
  File "/home/ubuntu/.local/lib/python3.6/site-packages/s3fs/__init__.py", line 1, in <module>
    from .core import S3FileSystem, S3File
  File "/home/ubuntu/.local/lib/python3.6/site-packages/s3fs/core.py", line 14, in <module>
    import aiobotocore
  File "/home/ubuntu/.local/lib/python3.6/site-packages/aiobotocore/__init__.py", line 1, in <module>
    from .session import get_session, AioSession
  File "/home/ubuntu/.local/lib/python3.6/site-packages/aiobotocore/session.py", line 6, in <module>
    from .client import AioClientCreator, AioBaseClient
  File "/home/ubuntu/.local/lib/python3.6/site-packages/aiobotocore/client.py", line 12, in <module>
    from .utils import AioS3RegionRedirector
  File "/home/ubuntu/.local/lib/python3.6/site-packages/aiobotocore/utils.py", line 10, in <module>
    from botocore.exceptions import (
ImportError: cannot import name 'InvalidIMDSEndpointError'

更多详情:
操作系统:Ubuntu 18.04
Python 3.6 版

pip3 show s3fs

名称:s3fs
版本:0.5.1
摘要:基于 S3 的便捷文件系统接口
主页:http://github.com/dask/s3fs/
位置:/home/ubuntu/.local/lib/python3.6/site-packages
要求:fsspec、aiobotocore

 pip3 show botocore

名称:botocore
版本:1.19.24
总结:boto 3 的底层数据驱动核心。
主页:https://github.com/boto/botocore
位置:/home/ubuntu/.local/lib/python3.6/site-packages 需要:jmespath、urllib3、python-dateutil

  pip3 show aiobotocore

名称:aiobotocore
版本:1.2.0
摘要:使用 botocore 和 aiohttp 的 aws 服务异步客户端
主页:https://github.com/aio-libs/aiobotocore
位置:/home/ubuntu/.local/lib/python3.6/site-packages
需要:botocore、wrapt、aioitertools、aiohttp

 pip3 show boto3

名称:boto3
版本:1.16.52
摘要:适用于 Python 的 AWS 开发工具包
主页:https://github.com/boto/boto3
位置:/home/ubuntu/.local/lib/python3.6/site-packages
需要:botocore、s3transfer、jmespath


有什么想法吗?

谢谢

【问题讨论】:

    标签: python-3.x boto3 ubuntu-18.04 python-s3fs


    【解决方案1】:

    升级botocore解决了这个问题

     pip3 install botocore==1.19.52
    

    【讨论】:

      【解决方案2】:

      您还可以将 aiobotocore 降级到旧版本 1.1.2。 S3fs==0.5.1 仅取决于 aiobotocore >= 1.0.1。使用johnnydep 可视化依赖树(pip install johnnydep

      $ johnnydep s3fs==0.5.1
      
      s3fs==0.5.1                              Convenient Filesystem interface over S3
      ├── aiobotocore>=1.0.1                   Async client for aws services using botocore and aiohttp
      │   ├── aiohttp>=3.3.1                   Async http client/server framework (asyncio)
      │   │   ├── async-timeout<4.0,>=3.0      Timeout context manager for asyncio programs
      │   │   ├── attrs>=17.3.0                Classes Without Boilerplate
      │   │   ├── chardet<4.0,>=2.0            Universal encoding detector for Python 2 and 3
      │   │   ├── multidict<7.0,>=4.5          multidict implementation
      │   │   ├── typing-extensions>=3.6.5     Backported and Experimental Type Hints for Python 3.5+
      │   │   └── yarl<2.0,>=1.0               Yet another URL library
      │   │       ├── idna>=2.0                Internationalized Domain Names in Applications (IDNA)
      │   │       └── multidict>=4.0           multidict implementation
      │   ├── aioitertools>=0.5.1              itertools and builtins for AsyncIO and mixed iterables
      │   │   └── typing_extensions>=3.7       Backported and Experimental Type Hints for Python 3.5+
      │   ├── botocore<1.19.53,>=1.19.52       Low-level, data-driven core of boto 3.
      │   │   ├── jmespath<1.0.0,>=0.7.1       JSON Matching Expressions
      │   │   ├── python-dateutil<3.0.0,>=2.1  Extensions to the standard Python datetime module
      │   │   │   └── six>=1.5                 Python 2 and 3 compatibility utilities
      │   │   └── urllib3<1.27,>=1.25.4        HTTP library with thread-safe connection pooling, file post, and more.
      │   └── wrapt>=1.10.10                   Module for decorators, wrappers and monkey patching.
      └── fsspec>=0.8.0                        File-system specification
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-31
        • 2014-10-10
        • 2014-09-20
        • 2014-08-28
        • 2014-06-10
        • 2016-05-16
        • 2019-05-25
        • 2017-04-22
        相关资源
        最近更新 更多