subprocess.CalledProcessError:Command" curl ..."返回非零退出状态1

时间:2017-03-11 14:27:05

标签: python curl subprocess python-3.4

我有一个非常奇怪的案子。我在桌面win10 pro(64Bit)和Python3.4.3上使用脚本正常工作。当我在笔记本上启动相同的脚本(win10 home 64Bit,python3.4.3)时,它不再起作用了。

代码是:

import json
from pprint import pprint
import os, sys
from subprocess import check_output
username = "ka...s"
playlist_tracks_file_path = 'F:\\EDU\\PYTHON\\njtest\\PLLs\\'
playlist_id = "7oCx..4d"
bearer = "BQDy...WVv3A"
`# ----------------------------------------------`
`# Get spotify playlist name from its playlist ID`
`# ----------------------------------------------`
PLL_URL = '\"https://api.spotify.com/v1/users/'+username+'/playlists/'+playlist_id+'\"'
PLL_curl_cmd = "curl -X GET "+PLL_URL+ " -H \"Accept: application/json\" -H \"Authorization: Bearer " +bearer+'\"'

dirc = check_output(PLL_curl_cmd, shell=True).decode('utf-8')
data =  json.loads(dirc)

和输出:

Traceback (most recent call last):
  File "F:\EDU\PYTHON\scripts\get_playlist-tracks.py", line 35, in <module>
dirc = check_output(PLL_curl_cmd, shell=True).decode('utf-8')
  File "C:\Users\j....\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 336, in check_output
**kwargs).stdout
  File "C:\Users\j....\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'curl -X GET "https://api.spotify.com/v1/users/ka...s/playlists/7oCx..4d" -H "Accept: application/json" -H "Accept: application/json" -H "Authorization: Bearer BQDy...WVv3A"' returned non-zero exit status 1.

请问,原因可能是什么?

希望,我没有忘记一些重要的信息。

0 个答案:

没有答案