linux 如何修复urllib 3 RuntimeError:请求依赖项'urllib 3'必须是版本>= 1.21.1,< 1.22?

wztqucjr  于 2023-06-29  发布在  Linux
关注(0)|答案(1)|浏览(160)

我是一个新的开发人员,正在学习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版本问题。
有人能帮我解决这个问题吗?或者给我指出正确的方向?
非常感谢。

xdyibdwo

xdyibdwo1#

在Mac上试试这个:sudo pip install urllib3==1.23 sudo pip install requests

相关问题