Python无法在cmd解释器或pycharm中找到导入

6gpjuf90  于 2023-01-26  发布在  PyCharm
关注(0)|答案(2)|浏览(124)

以下程序生成以下错误:

import os
#import time
import speech_recognition
from subprocess import call
from platform import python_version
home = os.path.expanduser("~")
from gtts import gTTS
from bs4 import BeautifulSoup
import pyaudio
import PyPDF2
print('Speech Recognition version ' + speech_recognition.__version__)

print('Attempting to read Preamble')
wav = "C:\\Users\\Owner\\PycharmProjects\\Government\\Governing_documents\\Preamble.wav"

recognizer = speech_recognition.Recognizer()
preamble = speech_recognition.AudioFile(wav)
with preamble as source:
    audio = recognizer.record(source)
type(audio)
recognizer.recognize_google(audio)

PYCHARM的错误消息:

C:\Users\Owner\PycharmProjects\Speech\venv\Scripts\python.exe C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py 
Traceback (most recent call last):
  File "C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py", line 3, in <module>
    import speech_recognition
ModuleNotFoundError: No module named 'speech_recognition'

指令提示:

C:\Users\Owner\PycharmProjects\Speech>python Wav_to_Text.py
Traceback (most recent call last):
  File "C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py", line 3, in <module>
    import speech_recognition
ModuleNotFoundError: No module named 'speech_recognition'

我试着修改环境变量以确保库是可见的。我检查了包的安装位置以及与PATH变量匹配的位置。它们仍然在PyCharm和cmd中给予我一个错误

bvn4nwqk

bvn4nwqk1#

pip install pocketsphinx PyAudio google-api-python-client vosk whisper

在终端运行此命令并通知我们发生了什么
这将安装所有的必需品

0ve6wy6x

0ve6wy6x2#

只是需要调整pycharm中的项目文件。我也有一个坏的参考3. 9时,它应该是3. 11。一切现在都工作。

相关问题