2013-09-30 51 views
2

我試圖使用Soundcloud-Python庫來利用Soundcloud API。我按照指示使用pip install soundcloud進行安裝,並且沒有報告錯誤。不知道我在這裏做錯了什麼。ImportError:嘗試導入Soundcloud時無法導入名稱get_content_type

錯誤跟蹤:

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 
+0

您是否安裝了另一個依賴包'requests'?如果沒有,請執行'pip install requests',然後重試。 –

回答

4

這是造成在請求和的SoundCloud的Python的版本不匹配的錯誤。我只是推動了PyPi的更新。嘗試使用pip install安裝/升級 - 升級soundcloud並讓我知道它是如何發展的。

+0

非常感謝! [Hoorah(https://twitter.com/WillemLabu/status/384649359427506177)! – Labu

+0

得到相同的錯誤。升級說:對於soundcloud,fudge == 1.0.3的要求已經是最新的,請求> = 0.14.0,simplejson> = 2.0但仍然是相同的錯誤。 –

相關問題