簡體   English   中英

ModuleNotFoundError:沒有名為“六”的模塊,六已安裝

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

我正在嘗試在我的 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 行是“from Six.moves import urllib”。 運行pip show six看起來不錯,版本 1.15.0 安裝在 python3.7/site-packages 中,我也在使用 IDLE 版本 3.7,所以看起來問題不存在。 我已經嘗試卸載並重新安裝六個,以及pip install --ignore-installed sixpython -m pip install six ,雖然兩者都運行沒有問題,但都沒有解決我的問題。 我不知道還有什么可以嘗試的,有人可以幫我解決這個問題嗎?

你在使用 virtualenv 嗎? 您可以嘗試運行 pip -V 來查看您使用的是正確的 pip 嗎? 一個常見的錯誤是認為由於 python 的默認環境變量指向某個版本,因此 pip 的默認環境變量是相同的。 如果您不在 virtualenv 下工作,這可能是問題所在。 我建議添加有關您的問題的更多信息,因為它可能源於多種原因

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM