简体   繁体   English

安装错误:pip install gTTS (Google-Text-To-Speech) 错误

[英]Installation error : pip install gTTS (Google-Text-To-Speech) error

Getting syntax error while running the following command on terminal:在终端上运行以下命令时出现语法错误:

pip install gTTS File "", line 1 pip install gTTS ^ pip install gTTS 文件“”,第 1 行 pip install gTTS ^

在此处输入图片说明

That's not how you run pip... You run it from the system shell like this这不是你运行 pip 的方式......你像这样从系统shell 运行它

> pip install gTTS

or或者

> python -m pip install gTTS

If you want to run it from inside a script, or a python shell you do it like this如果你想从脚本或python shell 中运行它,你可以这样做

import pip

def install(package):
    pip.main(['install', package])

# Example
if __name__ == '__main__':
    install('gTTS')

If you had installed Anaconda IDE , the installation gets much hassle-free as it eliminates the headaches of trying to figure out which version/release of package X is compatible with which version/release of package Y.如果您已经安装了Anaconda IDE ,安装就会变得非常轻松,因为它消除了试图找出软件包 X 的哪个版本/发行版与软件包 Y 的哪个版本/发行版兼容的麻烦。

Just open the Conda prompt shell and type the following command and hit Enter :只需打开 Conda 提示符 shell并键入以下命令并按Enter

pip install gTTS

Voila!瞧! The package will be successfully installed in a jiffy!该软件包将在瞬间成功安装!

I mentioned in my reply to sehafoc I tried running the command from shell and started getting another error "no module name pip", so I installed pip by running following commands:我在对 sehafoc 的回复中提到我尝试从 shell 运行命令并开始收到另一个错误“没有模块名称 pip”,所以我通过运行以下命令安装了 pip:

  1. Downloaded pip script $ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py下载 pip 脚本 $ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py

  2. Executed the pip script by running following command $ sudo python get-pip.py通过运行以下命令执行 pip 脚本 $ sudo python get-pip.py

  3. Install gTTS module $ sudo pip install gTTS安装 gTTS 模块 $ sudo pip install gTTS

If you can't use your pip on your cmd.如果您无法在 cmd 上使用 pip。 But first thing, you have to install your pip with syntax:但首先,您必须使用以下语法安装 pip:

python -m install pip 

And don't forget to add python to your path, and then type this syntax to your cmd并且不要忘记将 python 添加到您的路径中,然后在您的 cmd 中输入此语法

python -m pip install gtts

and your gtts will dowloaded automatically你的gtts会自动下载

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

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