gpt4 book ai didi

linux - 如何修复 urllib3 RuntimeError : Requests dependency 'urllib3' must be version >= 1. 21.1,< 1.22?

转载 作者:IT王子 更新时间:2023-10-29 00:43:41 26 4
gpt4 key购买 nike

我是一名新开发人员,正在学习使用 Python 3.4.2 编写代码。我在 Raspberry Pi3 上运行 Debian Linux。全新安装后,我都做了

sudo apt-get update

sudo apt-get upgrade

让一切都保持最新。

我正在尝试测试一段将文件上传到 Dropbox 的代码:

import dropbox
import urllib3

authkey = (my dropbox dev auth key)

with open('test.csv','rb') as f:
dbx = dropbox.Dropbox(authkey)
dbx.files_upload(f.read(), '/test.csv')

现在,我不知道实际的 Dropbox 代码是否正确,因为当我在 Python shell 中运行脚本时出现以下错误:

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
assert minor >= 21
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/dbtest.py", line 1, in <module>
import dropbox
File "/usr/local/lib/python3.4/dist-packages/dropbox/__init__.py", line 3, in <module>
from .dropbox import __version__, Dropbox, DropboxTeam, create_session # noqa: F401
File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 18, in <module>
import requests
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

对我来说,这表明我的 urllib3 安装有问题,所以我转到 bash shell 并键入:

sudo pip3 install --update urllib3

并得到完全相同的错误信息:

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
assert minor >= 21
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 22, in <module>
import requests, six
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 61, in <module>
raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

我有其他使用 Twilio 发送 SMS 消息的脚本,它们也不再工作,产生相同的错误消息,引用 urllib3 版本问题。

谁能帮我解决这个问题或指出正确的方向?

非常感谢。

最佳答案

在 Mac 上试试这个:
sudo pip install urllib3==1.23
然后
sudo pip 安装请求

关于linux - 如何修复 urllib3 RuntimeError : Requests dependency 'urllib3' must be version >= 1. 21.1,< 1.22?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44397101/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com