简体   繁体   English

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

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

I am getting this error when importing gtts module.导入 gtts 模块时出现此错误。 I have successfully installed gtts but its is giving :: "ModuleNotFoundError: No module named 'certifi'"我已经成功安装了 gtts,但它给出了 ::“ModuleNotFoundError: No module named 'certifi'”

I have also installed certifi using "pip install certifi".我还使用“pip install certifi”安装了certifi。

在此处输入图片说明

Okay, So this error says "certifi" Module is not found.好的,所以这个错误说没有找到“certifi”模块。 There can be many reasons for this but for your problem it seems like where you have installed certifi and from where you are accessing it( jupyter notebook) both location are different.这可能有很多原因,但对于您的问题,似乎您安装 certifi 的位置和访问它的位置(jupyter notebook)这两个位置都不同。 So if you are on windows just run powershell or command prompt and run: python when the python shell appears do:因此,如果您在 Windows 上,只需运行 powershell 或命令提示符并在出现 python shell 时运行:python 执行以下操作:

import sys
print(sys.executable)

Note the path, Now open up your Jupyter notebook and do the same:记下路径,现在打开你的 Jupyter notebook 并执行相同的操作:

import sys
print(sys.executable)

if both the paths are not same that means you have been installing the certifi library to somewhere else, Now you need to check from where the python was running inside the jupyter notebook, if it was running from a conda virtual environment then you will first have to activate it either from the cmd/powershell or from the conda prompt then you just simply install the certifi library inside that using pip.如果两个路径不同,这意味着您已经将 certifi 库安装到其他地方,现在您需要检查 python 在 jupyter notebook 中运行的位置,如果它是从 conda 虚拟环境运行的,那么您将首先拥有要从 cmd/powershell 或从 conda 提示符激活它,那么您只需使用 pip 在其中安装 certifi 库。

Once you are confirmed that the path were same in both the python shell and the jupyter notebook then in the same command prompt/power shell type:一旦确认路径在 python shell 和 jupyter notebook 中相同,然后在相同的命令提示符/电源 shell 类型中:

pip list | findstr "certifi"

if you see a result that means certifi is installed to the same python location from where you are using it (ie from the jupyter notebook)如果您看到一个结果,这意味着 certifi 已安装到您使用它的同一个 python 位置(即来自 jupyter 笔记本)

Example from my PC:来自我的 PC 的示例:

Different Python Paths不同的 Python 路径

But Once I activated the conda environment which the jupyter notebook was using then:但是一旦我激活了 jupyter notebook 使用的 conda 环境:

Same Python Paths相同的 Python 路径

Checking for a module ("requests" in my case) if it is installed or not检查模块(在我的情况下为“请求”)是否已安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM