首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PermissionError:[Errno 13]权限被拒绝- Spotipy

PermissionError:[Errno 13]权限被拒绝- Spotipy
EN

Stack Overflow用户
提问于 2021-02-09 03:05:24
回答 1查看 180关注 0票数 0

我正在尝试使用Spotipy Python库调用Spotify API。我收到一个'PermissionError: [Errno 13] Permission denied'错误。

我使用的是以Debian为操作系统的GCP计算引擎。

错误在下面

代码语言:javascript
复制
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/client.py", line 1307, in current_use
r_recently_played<br>
    before=before,<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/client.py", line 291, in _get<br>
    return self._internal_call("GET", url, payload, kwargs)<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/client.py", line 221, in _internal_ca
ll<br>
    headers = self._auth_headers()<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/client.py", line 212, in _auth_header
s<br>
    token = self.auth_manager.get_access_token(as_dict=False)<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 484, in get_access_t
oken<br>
    "code": code or self.get_auth_response(),<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 439, in get_auth_res
ponse<br>
    return self._get_auth_response_local_server(redirect_port)<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 405, in _get_auth_re
sponse_local_server<br>
    server = start_local_http_server(redirect_port)<br>
  File "/home/#####/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 1227, in start_local
_http_server<br>
    server = HTTPServer(("127.0.0.1", port), handler)<br>
  File "/usr/lib/python3.7/socketserver.py", line 452, in __init__<br>
    self.server_bind()<br>
  File "/usr/lib/python3.7/http/server.py", line 137, in server_bind<br>
    socketserver.TCPServer.server_bind(self)<br>
  File "/usr/lib/python3.7/socketserver.py", line 466, in server_bind<br>
    self.socket.bind(self.server_address)<br>
PermissionError: [Errno 13] Permission denied<br>

代码示例如下

代码语言:javascript
复制
import spotipy 
from spotipy.oauth2 import SpotifyOAuth

scope = 'user-read-recently-played'

sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))

played = sp.current_user_recently_played()

我已经在我认为是相关目录的地方做了chmod 0775 -R,但仍然卡住了。

EN

回答 1

Stack Overflow用户

发布于 2021-02-09 03:24:27

我建议尝试使用不同的方法。下面是我在Spotify管道中使用的内容:

代码语言:javascript
复制
import spotipy
import spotipy.util as util
import os

un = os.environ['un']
scope = 'user-read-recently-played'
cid = os.environ['cid']
csid = os.environ['csid']
redr = r'http://localhost:8888/callback/'

token = util.prompt_for_user_token(un,scope,cid,csid,redr)
sp = spotipy.Spotify(auth=token)
results = sp.current_user_recently_played()

其中un是我的用户名,cidcsid是我的开发者账户的密钥/秘密密钥,redr只是重定向的本地网页。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66107769

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档