简体   繁体   English

ModuleNotFoundError:没有名为“六”的模块,六已安装

[英]ModuleNotFoundError: No module named 'six' , Six is already installed

I am trying to run this pretty simple text-to-speech program on my Mac:我正在尝试在我的 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")

but when I try to run it I am getting this error:但是当我尝试运行它时,我收到了这个错误:

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'

The line 6 it seems to be referring to in tts.py is "from six.moves import urllib", if that matters.如果重要的话,它似乎在 tts.py 中引用的第 6 行是“from Six.moves import urllib”。 Running pip show six looks fine, with version 1.15.0 installed in python3.7/site-packages and I'm using IDLE version 3.7 as well so it doesn't seem like the problem is there.运行pip show six看起来不错,版本 1.15.0 安装在 python3.7/site-packages 中,我也在使用 IDLE 版本 3.7,所以看起来问题不存在。 I have tried uninstalling and reinstalling six, as well as pip install --ignore-installed six and python -m pip install six and while both run without issue, neither have fixed my problem.我已经尝试卸载并重新安装六个,以及pip install --ignore-installed sixpython -m pip install six ,虽然两者都运行没有问题,但都没有解决我的问题。 I don't know what else to try, can anyone help me out with this?我不知道还有什么可以尝试的,有人可以帮我解决这个问题吗?

Are you working with a virtualenv?你在使用 virtualenv 吗? Can you try and run pip -V to see you are using the right pip?您可以尝试运行 pip -V 来查看您使用的是正确的 pip 吗? A common mistake is thinking that since the default environment variable for python points to a certain version then it is the same for pip.一个常见的错误是认为由于 python 的默认环境变量指向某个版本,因此 pip 的默认环境变量是相同的。 If you are not working under a virtualenv this might be the problem.如果您不在 virtualenv 下工作,这可能是问题所在。 I suggest adding more information about your issue as it can stem from many reasons我建议添加有关您的问题的更多信息,因为它可能源于多种原因

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

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