python - ModuleNotFoundError:没有名为“六”的模块,六已安装
问题描述
我正在尝试在我的 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 six
and python -m pip install six
and 虽然两者都运行没有问题,但都没有解决我的问题。我不知道还有什么可以尝试的,有人可以帮我解决这个问题吗?
解决方案
你在使用 virtualenv 吗?您可以尝试运行 pip -V 来查看您使用的是正确的点子吗?一个常见的错误是认为由于 python 的默认环境变量指向某个版本,因此 pip 的默认环境变量是相同的。如果您不在 virtualenv 下工作,这可能是问题所在。我建议添加有关您的问题的更多信息,因为它可能源于多种原因
推荐阅读
- javascript - React hooks:在子函数内部的 onClick 函数内部更改父函数的状态
- c# - 如何使用 Swashbuckle.AspNetCore 在 Swagger 模式中将自定义泛型类型公开为字符串
- mysql - 为什么用 describe 显示时 int 在 mysql 中没有显示大小;
- xml - 如何打印xml字典值中的所有键
- sql - 如何更新具有重复名称的表?
- python - 在 Python 中将反斜杠重新分配给三个点
- flutter - 在 Flutter 中更改字符串中括号内的所有文本颜色
- php - Laravel Lumen 7 API 端点在日期参数上失败
- css - 如何使网格中的标题与正文对齐?
- java - 当我启动 JavaFX 应用程序时退出代码(-1073741819)