模块未发现错误:没有名为'six'的模块,已经安装了六个



我正试图在我的Mac上运行这个非常简单的文本到语音程序:

# Import the required module for text 
# to speech conversion
from gtts import gTTS

# This module is imported so that we can 
# play the converted audio
import os

# The text that you want to convert to audio
mytext = 'Welcome to geeksforgeeks!'

# Language in which you want to convert
language = 'en'

# Passing the text and language to the engine, 
# here we have marked slow=False. Which tells 
# the module that the converted audio should 
# have a high speed
myobj = gTTS(text=mytext, lang=language, slow=False)

# Saving the converted audio in a mp3 file named
# welcome 
myobj.save("welcome.mp3")

# Playing the converted file
os.system("mpg321 welcome.mp3")

但是当我尝试运行它时,我得到了这个错误:

Traceback (most recent call last):
File "/Users/name/Documents/University/Intro to Python/Random/texttospeech.py", line 3, in <module>
from gtts import gTTS
File "/Users/name/Documents/University/Intro to Python/Random/gtts/__init__.py", line 3, in <module>
from .tts import gTTS, gTTSError
File "/Users/name/Documents/University/Intro to Python/Random/gtts/tts.py", line 6, in <module>
from six.moves import urllib
ModuleNotFoundError: No module named 'six'

它在tts.py中似乎指的行6是"0";从six.moves导入urllib";,如果这很重要的话。运行pip show six看起来不错,版本1.15.0安装在python3.7/site-package中,我也使用IDLE版本3.7,所以看起来没有问题。我已经尝试卸载并重新安装了六个,以及pip install --ignore-installed sixpython -m pip install six,虽然两者都运行没有问题,但都没有解决我的问题。我不知道还能做什么,有人能帮我吗?

您正在使用虚拟机吗?你能试着运行pip-V看看你用的是正确的pip吗?一个常见的错误是认为,由于python的默认环境变量指向某个版本,因此pip也是如此。如果你不是在虚拟环境下工作,这可能就是问题所在。我建议添加更多关于你的问题的信息,因为它可能源于许多原因

相关内容

  • 没有找到相关文章

最新更新