Reputation: 83
Forgive me if this is a redundant question. I viewed a couple of similar posts and I do believe my issue is unique. I am making a simple AI Assistant using a tutorial on geeksforgeeks. Link below:
https://www.geeksforgeeks.org/build-a-virtual-assistant-using-python/
I wanted to tweak this to be more specific to my needs, and I think I have it all figured out, including replacing import speech_recognition as sr
with it's python3 counterpart, import SpeechRecognition as sr
. I am using PyCharm Community as my IDE, and for those that know it, it allows you to install missing modules used by import
by mousing over them and clicking the prompt to install the module. Long story short, this doesn't work for SpeechRecognition. It's showing No module named 'SpeechRecognition'
despite clicking the prompt several times and seeing that it successfully installed.
I went to the Python Terminal and tried to do this manually with the following:
>> pip3 install SpeechRecognition
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Users\[user]\PycharmProjects\[my project]\venv\Scripts\python.exe -m pip install --upgrade pip' command.
>> C:\Users\[user]\PycharmProjects\[my project]\venv\Scripts\python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in C:\Users\[user]\PycharmProjects\[my project]\venv\lib\site-packages (21.1.2)
Collecting pip`
Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
Attempting uninstall: pip`
Found existing installation: pip 21.1.2
Uninstalling pip-21.1.2:
Successfully uninstalled pip-21.1.2
Successfully installed pip-21.3.
>> pip3 install SpeechRecognition
Requirement already satisfied: pip in C:\Users\[user]\PycharmProjects\[my project]\venv\lib\site-packages (3.8.1)
I'm fairly new to Python and coding in general, but from I can tell it is installed. However, when I run the program, it returns the following error:
Traceback (most recent call last):
File "C:\Users\[user]\PycharmProjects\[my project]\main.py", line 2, in <module>
import SpeechRecognition as sr
ModuleNotFoundError: No module named 'SpeechRecognition'
Not sure what I'm doing wrong here, but any help would be appreciated.
Thanks, and cheers.
Upvotes: 0
Views: 1234
Reputation: 6857
I think I have it all figured out, including replacing
import speech_recognition as sr
with it's python3 counterpart,import SpeechRecognition as sr
This is your issue. I can't find anywhere that says you should import the library that way. All the official examples, and the official readme, state that it should be imported via:
import speech_recognition as sr
Again I'm not sure why you thought it should be imported differently just because you're using Python 3. I will say that GeeksForGeeks is generally not recognized as a good source of information by this site's community. I highly recommend using other sites, and also always starting from official sources.
Upvotes: 2