speech_recognition: ModuleNotFoundError: No module named 'speech_recognition' in Fedora 26
I already installed speech_recognition
and trying to import speech_recognition
it gave me ModuleNotFoundError: No module named 'speech_recognition'
Hear is my python code
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as mp:
print('say')
audio = r.listen(mp)
try:
print(r.recognize_google(audio))
except:
pass
Here is console error
Traceback (most recent call last):
File “<ipython-input-7-9e3bdf5986c0>”, line 1, in <module> runfile(‘/home/coder/Documents/python/speechtotext.py’, wdir=‘/home/coder/Documents/python’)
File “/usr/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py”, line 710, in runfile execfile(filename, namespace)
File “/usr/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py”, line 101, in execfile exec(compile(f.read(), filename, ‘exec’), namespace)
File “/home/coder/Documents/python/speechtotext.py”, line 8, in <module> import speech_recognition as sr
ModuleNotFoundError: No module named ‘speech_recognition’
System information
My system is <Fedora 26>.
My Python version is <Python 2.7.14> in fedora 26 but I upgraded it to 3.6
My Pip version is <pip 9.0.1>.
My SpeechRecognition library version is ❤️.7.1>.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 36 (1 by maintainers)
Try
sudo pip3 install --upgrade speechrecognition
try pip3 install --upgrade speechrecognition
Solution
Note: I am using a PC. Use
pip3 install --upgrade speechrecognition
as pointed out by Mardii-D-King.Observation
‘pip install SpeechRecognition’ installed the package and I could also import it from cmd followed by checking its version:
However
Running the same from Jupyter Notebook threw the same error as mentioned above. So, trying the following solved it. Run this from inside Jupyter Notebook:
And it was working for me…
If you use the python version bellow 3.x.x then try sudo pip3 install --upgrade speechrecognition And If you use pycharm or ID then go to File > Settings > Project: XX > Project Interpreter >
-> install Package
You must have installed SpeechRecognition from Terminal - cmd and you must be using anaconda or other package libraries like that. What has happened here is that your speech SpeechRecognition has installed in your python local directory. you have to copy it from there and paste it in your anaconda library.
Follow the steps:
This will fix the problem.
facing the same problem
i-got-the-same-problem-as @rajnishcoder -and-i had-tried-to-resolve-it-by-using-pip3-then-also-i-am-getting-same-module-not-found-error
Thanks @staRk22 …your solution works!!
first-check-the-speech-recognition(sr)-file-from-the-given-path-from-your-terminal-in-that-folder-two-file-of-sr-is-their 1-is-speech_recognition 2-is-SpeechRecognition-3.8.1.dist-info copy-this-both-file-and-paste-it-into-anaconda’s-SITE-PACKAGE-file remember-where-your-anaconda’s-file-is example-D:\anaconda\Lib\site-packages the-above-mention-directory-is-where-my-anaconda-file-is
File “jarvis_main_code.py”, line 49, in <module> Listen() File “jarvis_main_code.py”, line 35, in Listen with sr.Microphone as source : AttributeError: enter
Traceback (most recent call last): File “jarvis_main_code.py”, line 48, in <module> Listen() File “jarvis_main_code.py”, line 34, in Listen r = sr.Recognition() AttributeError: module ‘speech_recognition’ has no attribute ‘Recognition’
All of this did not work for me. I cannot find SpeechRecognition in the installable packages for pyCharm. I have installed SpeechRecognition everywhere. In my pytorch environment, conda, python 3.6 as well. Nothing helped. Changing my code from
import speech_recognition as sr
toimport speechrecognition as sr
did not make a difference. I am a windows 10 Home user. My interpreter is python 3.6 in conda. I realized I have another .conda folder on my laptop and copied the speech_recognizer file from the other environments there into the /lib/site_packages section. It worked for me, so I hope it helps others that face the same issue.I have the same problem Here is my solution
facing-same-problem-even-after upgrading-speech-recognition-using-pip3-and-if-i-run-it-again-in-the-terminal-it-say-file-already-exist-but-in-python-shell-it-say-module-not-found-error