Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在树莓皮3模型B上使用python3中的GTT_Python_Python 2.7_Raspberry Pi_Raspberry Pi3 - Fatal编程技术网

如何在树莓皮3模型B上使用python3中的GTT

如何在树莓皮3模型B上使用python3中的GTT,python,python-2.7,raspberry-pi,raspberry-pi3,Python,Python 2.7,Raspberry Pi,Raspberry Pi3,我在raspberry pi中为gTTs项目使用上面的代码,并且我已经使用下面的代码将gTTs安装到我的pi中 import gtts blabla = ("Spoken text") tts = gTTS(text=blabla, lang='en') tts.save("test.mp3") 在运行py脚本之后,我遇到了以下错误 pip3 install gTTs $python test2.py 回溯(最近一次呼叫最后一次): 文件“test2.py”,第3行,在 tts=gTTS(t

我在raspberry pi中为gTTs项目使用上面的代码,并且我已经使用下面的代码将gTTs安装到我的pi中

import gtts
blabla = ("Spoken text")
tts = gTTS(text=blabla, lang='en')
tts.save("test.mp3")
在运行py脚本之后,我遇到了以下错误

pip3 install gTTs
$python test2.py
回溯(最近一次呼叫最后一次):
文件“test2.py”,第3行,在
tts=gTTS(text=blabla,lang='en')
NameError:未定义名称“gTTS”

因此,任何人都可以帮助我解决这个问题。

您使用
pip3
安装了python 3的包,但是您使用
python test2.py
运行python脚本,它将以pyton2.7的形式启动python,请尝试使用
python3 test2.py
运行它。它也应该是
来自gtts import gtts
$ python test2.py
Traceback (most recent call last):
  File "test2.py", line 3, in <module>
    tts = gTTS(text=blabla, lang='en')
NameError: name 'gTTS' is not defined