ImportError:尝试导入soundcloud时无法导入名称get_content_type

时间:2013-09-30 03:09:50

标签: python importerror

我正在尝试使用Soundcloud-Python库来使用Soundcloud API。我安装了它,因为我被指示使用pip install soundcloud并且我没有报告错误。不知道我在这里做错了什么。

错误追踪:

Traceback (most recent call last):
  File "uploadToSoundcloud.py", line 1, in <module>
    import soundcloud
  File "/usr/local/lib/python2.7/dist-packages/soundcloud/__init__.py", line 8, in <module>
    from soundcloud.client import Client
  File "/usr/local/lib/python2.7/dist-packages/soundcloud/client.py", line 5, in <module>
    from soundcloud.request import make_request
  File "/usr/local/lib/python2.7/dist-packages/soundcloud/request.py", line 14, in <module>
    from requests.packages.urllib3.filepost import get_content_type, iter_fields
ImportError: cannot import name get_content_type

代码:

import soundcloud

client = soundcloud.Client(
    client_id='f3ddcf1f3e069b44a21115d0d58d6005',
    client_secret='**censored**',
    username='**censored**',
    password='**censored**'
)

print client.get('/me').username

1 个答案:

答案 0 :(得分:4)

这是由于请求版本和soundcloud-python不匹配导致的错误。我刚刚将更新推送到PyPi。尝试使用pip install --upgrade soundcloud进行安装/升级,让我知道它是怎么回事。