我試圖使用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
您是否安裝了另一個依賴包'requests'?如果沒有,請執行'pip install requests',然後重試。 –