【发布时间】:2019-10-16 16:52:08
【问题描述】:
我正在尝试在 python/django 项目中使用 boto3。我以前做过,但是在运行 localhost 时它向我发出了警告——这破坏了我试图运行的请求。我在python 3.7版上。我已经在 boto3 的 GitHub 存储库中看到了这个问题,大多数是指运行 pytest 时出现的错误。我的问题似乎与最新的 PR 不符
https://github.com/boto/botocore/issues/1615
我不太确定该转向哪里。非常感谢任何建议。
from . import urllib3
File "/Users/neilballard/.local/share/virtualenvs/Volley-ldVCpc8_/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/Users/neilballard/.local/share/virtualenvs/Volley-ldVCpc8_/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 38, in <module>
from .response import HTTPResponse
File "/Users/neilballard/.local/share/virtualenvs/Volley-ldVCpc8_/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/response.py", line 9, in <module>
from ._collections import HTTPHeaderDict
File "/Users/neilballard/.local/share/virtualenvs/Volley-ldVCpc8_/lib/python3.7/site-packages/botocore/vendored/requests/packages/urllib3/_collections.py", line 1, in <module>
from collections import Mapping, MutableMapping
File "<frozen importlib._bootstrap>", line 1032, in _handle_fromlist
File "/Users/neilballard/.local/share/virtualenvs/Volley-ldVCpc8_/lib/python3.7/collections/__init__.py", line 52, in __getattr__
DeprecationWarning, stacklevel=2)
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
我已经确认是“import boto3”导致了这个问题。我已经删除了 boto3,重新安装,尝试了不同版本的 boto3 和 urllib。
【问题讨论】:
-
这适用于本地主机吗?我没有使用 pytest。
-
实际上,它是一个普通的python警告过滤器,所以忽略它应该可以工作。更多信息:
https://docs.python.org/3/library/warnings.html#warning-filter1 -
它打破了我的要求。在下面发布解决方案