You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决Python调用Google My Business API的google.auth.transport.rest缺失错误

解决方案

1. 修正导入语句(优先尝试)

google.auth.transport.rest.AuthorizedSession 是基于httplib2的实现,如果你使用的是requests库,正确的导入路径应该是从google.auth.transport.requests中获取AuthorizedSession,修改代码开头为:

import google.auth
from google.auth.transport.requests import Request, AuthorizedSession

2. 重新安装完整依赖包

如果坚持使用rest模块,先卸载现有冲突包,再安装完整依赖:

pip uninstall -y google google-auth google-auth-oauthlib
pip install google-auth google-auth-oauthlib google-auth-httplib2

3. 确认Python环境一致性

确保运行代码的Python环境与pip安装的环境一致:

  • 若使用Python3,对应使用pip3安装:
pip3 install google-auth google-auth-oauthlib google-auth-httplib2
  • 查看当前Python解释器路径:
which python  # 或 which python3
  • 查看pip对应的Python路径:
pip --version  # 或 pip3 --version

确保两者路径匹配。

内容的提问来源于stack exchange,提问作者ertugrulozturk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 17:45:55