python - 安装 google api 客户端以从 python 发送电子邮件
问题描述
我正在尝试学习如何使用 Gmail API 在 python 中发送电子邮件。
我脚本的第一行之一:
from googleapiclient.discovery import build
给我错误:
No module named googleapiclient.discovery
我正在尝试通过执行以下操作来安装 googleapiclient:
sudo pip install --upgrade google-api-python-client
这似乎做所有正确的事情,直到它说:
Installing collected packages: httplib2, uritemplate, rsa, cachetools, pyasn1-modules, google-auth, google-auth-httplib2, google-api-python-client
Found existing installation: httplib2 0.9.1
Cannot uninstall 'httplib2'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
我不确定这条消息是否会停止工作,但我仍然收到消息:
No module named googleapiclient.discovery
当我尝试运行我的代码时。任何建议都感激不尽!
解决方案
OP 面临着这里提到的类似问题。
在大多数情况下,使用--user
安装包的选项可以解决这个问题。在安装软件包之前。我们必须先卸载google-api-python-client
。
pip uninstall google-api-python-client
现在install
使用该--user
选项的包。
pip install --user google-api-python-client
推荐阅读
- javascript - 如何提示用户再次尝试输入
- tcl - 如何在 tcl 中打印 argv?
- c++ - GCC 10.0.1 接受包含不在基本源字符集中的字符的标头名称
- javascript - 无法通过变量设置标题
- assembly - Dword 在 x86 程序集中做什么?
- java - 在 java geeksforgeeks 中的单链表末尾插入一个节点
- python - 是否有 cv2 函数/算法来跟踪相机的运动?
- ios - 如何在从 expo 裸工作流构建 iOS 应用程序时修复错误
- c# - Selenium 定位器如何定位子 div 类属性标签的列表
- python - 如何修复seaborn热图上的重叠yaxis