YouTube数据API返回配额超限错误,但我的配额为0

1 投票
1 回答
26 浏览
提问于 2025-04-14 15:43

我一直在用JupyterLab上课记笔记,我们在用YouTube的API做一些简单的调用,而我却是唯一一个一直出错的人。为了说明情况,这段代码就是导致错误的代码:

request = youtube.search().list(
        part="snippet",
        maxResults=5,
        q="pewdiepie",
        type="channel"
    )
response = request.execute()
response

这是错误信息:

---------------------------------------------------------------------------
HttpError                                 Traceback (most recent call last)
Cell In[7], line 7
      1 request = youtube.search().list(
      2         part="snippet",
      3         maxResults=5,
      4         q="pewdiepie",
      5         type="channel"
      6     )
----> 7 response = request.execute()
      8 response

File ~\pyenv\socialmining\Lib\site-packages\googleapiclient\_helpers.py:130, in positional.<locals>.positional_decorator.<locals>.positional_wrapper(*args, **kwargs)
    128     elif positional_parameters_enforcement == POSITIONAL_WARNING:
    129         logger.warning(message)
--> 130 return wrapped(*args, **kwargs)

File ~\pyenv\socialmining\Lib\site-packages\googleapiclient\http.py:938, in HttpRequest.execute(self, http, num_retries)
    936     callback(resp)
    937 if resp.status >= 300:
--> 938     raise HttpError(resp, content, uri=self.uri)
    939 return self.postproc(resp, content)

HttpError: <HttpError 403 when requesting https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=5&q=pewdiepie&type=channel&key=AIzaSyBX-q53U3O7s61AtwOSegJsxG-ZtQvHiJE&alt=json returned "The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.". Details: "[{'message': 'The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.', 'domain': 'youtube.quota', 'reason': 'quotaExceeded'}]">

我是在一个虚拟环境中运行Jupyter的,老师也是在虚拟环境中运行的,但他没有遇到问题。正如我所说,我在API上的配额是0,所以我实在搞不懂这是怎么回事。

1 个回答

0

看起来我在开启这个API的时候,不小心把其他所有服务也都开启了。后来我把那些服务关掉之后,一切就正常了。我真不知道我是怎么搞成这样的。

撰写回答