尝试运行代码时发生以下错误:
Traceback (most recent call last):
response = session.post(base_url, params={'query': filename_query})
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 805, in urlopen
if retries.is_retry(method, response.status, has_retry_after):
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 343, in is_retry
if not self._is_method_retryable(method):
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 331, in _is_method_retryable
if self.method_whitelist and method.upper() not in self.method_whitelist:
AttributeError: 'Retry' object has no attribute 'method_whitelist'
有人能帮我吗?
5条答案
按热度按时间1rhkuytd1#
我不知道你的具体情况,因为没有太多的信息。尽管如此,我在ApacheBeam管道中使用
requests
包时也遇到了同样的错误问题是,
method_whitelist
已被弃用,并从urllib3==1.26.0
中删除,如发布变更日志中所述我的解决方案是将
urllib
版本设置为以前的版本,将urllib3==1.25.11
添加到我的requirements.txt
tag5nh1u2#
我也遇到过类似的问题。在我的例子中,问题是pyfcm库没有更新。此库用于发送推送通知。我的问题通过更新这个库得到了解决。
stszievb3#
我通过安装
requests==1.26.0
和urllib3==1.26.2
解决了类似的问题。xggvc2p64#
使用
allowed_methods
代替method_whitelist
。后者在某个时候被删除,并被前者取代。yws3nbqq5#
使用allowed_methods代替method_whitelist。后者在某个时候被删除,并被前者取代。
有关Retry对象和现有输入选项的更多信息,请参见relevant urllib3 documentation