python-3.x aiobotocore -导入错误:无法导入名称“无效IMDSEndpointError”

lp0sw83n  于 2022-12-05  发布在  Python
关注(0)|答案(3)|浏览(223)

下面的代码引发导入异常

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

名称:s3 fs
版本号:0.5.1
摘要:S3上方便的文件系统接口
首页:http://github.com/dask/s3fs/
当前位置:/home/ubuntu/.local/lib/python3.6/站点包
需要: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、urllib 3、Python日期工具

pip3 show aiobotocore

产品名称:
版本号:1.2.0
摘要:使用botocore和aiohttp的aws服务异步客户端
首页:https://github.com/aio-libs/aiobotocore
当前位置:/home/ubuntu/.local/lib/python3.6/站点包
需要:botocore、wrapper、aioitertools、aiohttp

pip3 show boto3

产品名称:boto 3
版本号:1.16.52
总结:AWS SDK for Python
首页:https://github.com/boto/boto3
当前位置:/home/ubuntu/.local/lib/python3.6/站点包
需要:botocore、s3 transfer、jmespath
你知道是怎么回事吗?
谢谢

8cdiaqws

8cdiaqws1#

您也可以将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
gev0vcfq

gev0vcfq2#

升级botocore解决了问题

pip3 install botocore==1.19.52
hs1ihplo

hs1ihplo3#

我不得不为我的用例升级所有三个。

!pip install --upgrade boto3 botocore s3fs

相关问题