Python 2.7导入dropbox SDK错误

时间:2017-06-21 12:19:19

标签: python dropbox

在我的RaspberryPi上安装“dropbox SDK”后

pi@raspberrypi:~ $ sudo pip install dropbox
Downloading/unpacking dropbox
Downloading dropbox-7.3.1-py2-none-any.whl (416kB): 416kB downloaded
Downloading/unpacking requests>=2.5.1,!=2.6.1 (from dropbox)
Downloading requests-2.18.1-py2.py3-none-any.whl (88kB): 88kB downloaded
Requirement already satisfied (use --upgrade to upgrade): urllib3 in 
/usr/lib/python2.7/dist-packages (from dropbox)
Requirement already satisfied (use --upgrade to upgrade): six>=1.3.0 in 
/usr/lib/python2.7/dist-packages (from dropbox)
Downloading/unpacking certifi>=2017.4.17 (from requests>=2.5.1,!=2.6.1-
>dropbox)
Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB): 375kB downloaded
Downloading/unpacking chardet>=3.0.2,<3.1.0 (from requests>=2.5.1,!=2.6.1-
>dropbox)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB): 133kB downloaded
Downloading/unpacking idna>=2.5,<2.6 (from requests>=2.5.1,!=2.6.1->dropbox)
Downloading idna-2.5-py2.py3-none-any.whl (55kB): 55kB downloaded
Installing collected packages: dropbox, requests, certifi, chardet, idna
Found existing installation: requests 2.4.3
Not uninstalling requests at /usr/lib/python2.7/dist-packages, owned by OS
Found existing installation: chardet 2.3.0
Not uninstalling chardet at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed dropbox requests certifi chardet idna
Cleaning up...

当我的data_logger.py尝试“导入dropbox”

时出现此错误
pi@raspberrypi:~/cb_logging/bin $ sudo ./data_logger.py
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.9.1) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Traceback (most recent call last):
  File "./data_logger.py", line 17, in <module>
    import dropbox
  File "/usr/local/lib/python2.7/dist-packages/dropbox/__init__.py", line 3, in <module>
    from .dropbox import __version__, Dropbox, DropboxTeam, create_session  # noqa: F401
  File "/usr/local/lib/python2.7/dist-packages/dropbox/dropbox.py", line 18, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 90, in <module>
    from urllib3.exceptions import DependencyWarning
ImportError: cannot import name DependencyWarning
pi@raspberrypi:~/cb_logging/bin $

我不知道什么是错的。可以帮忙吗?

2 个答案:

答案 0 :(得分:3)

您在安装的请求模块中遇到问题。首先升级pip,然后尝试重新安装请求。

sudo apt-get install --only-upgrade python-pip
sudo pip uninstall requests
sudo pip install requests

答案 1 :(得分:0)

不确定是否为时已晚(可能对其他人有帮助),但我遇到了与Dropbox相同的问题,并且可以通过以下方式解决问题:

pip install urllib3 --upgrade

或特别是在我的情况下(差异脚本版本):

pip2.7 install urllib3 --upgrade