安装 gtts 时出错(导入 gTTS)google 文本到语音库

error while installing gtts (import gTTS) google text to speech library

导入 gtts 模块时出现此错误。我已经成功安装了 gtts,但它给出了 :: "ModuleNotFoundError: No module named 'certifi'"

我还使用“pip install certifi”安装了 certifi。

好的,所以这个错误显示“certifi”模块未找到。这可能有很多原因,但对于您的问题,您安装 certifi 的位置和访问它的位置(jupyter notebook)似乎都不同。因此,如果您在 windows 上,只需 运行 电源 shell 或命令提示符和 运行:python 当 python shell 出现时:

import sys
print(sys.executable)

注意路径,现在打开你的 Jupyter notebook 并执行相同的操作:

import sys
print(sys.executable)

如果两个路径不相同,这意味着您已经将 certifi 库安装到其他地方,现在您需要检查 python 在 jupyter notebook 中 运行ning 的位置,如果它是来自 conda 虚拟环境的 运行ning,那么您首先必须从 cmd/powershell 或从 conda 提示符激活它,然后您只需使用 pip 在其中安装 certifi 库即可。

一旦你确认 python shell 和 jupyter notebook 中的路径相同,然后在相同的命令 prompt/power shell 中输入:

pip list | findstr "certifi"

如果您看到的结果表明 certifi 安装到与您使用它的位置相同的 python 位置(即来自 jupyter notebook)

来自我的 PC 的示例:

Different Python Paths

但是一旦我激活了 jupyter notebook 使用的 conda 环境,然后:

Same Python Paths

Checking for a module ("requests" in my case) if it is installed or not