speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

ModuleNotFoundError: No module named 'speech_recognition' in Fedora 26

Open rajnishcoder opened this issue 7 years ago • 36 comments

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 "", line 1, in 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 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 <3.7.1>.

rajnishcoder avatar Nov 30 '17 02:11 rajnishcoder

Hi @rajnishcoder,

Can you post the following information?

  1. The path that speech_recognition has been installed to.
  2. The output of python -c "import sys; print(sys.path)".
  3. How you installed speech_recognition (e.g., using pip vs. using pip3).

I would also make sure first of all that it's installed with pip3 rather than pip, since IIRC that would default to installing for Python 2.

Uberi avatar Dec 04 '17 23:12 Uberi

Try sudo pip3 install --upgrade speechrecognition

mad0ba avatar Apr 03 '18 01:04 mad0ba

facing the same problem

esitharth avatar Jul 14 '18 17:07 esitharth

try pip3 install --upgrade speechrecognition

iamakhilk avatar Aug 06 '18 03:08 iamakhilk

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

25shady avatar Sep 01 '18 16:09 25shady

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

25shady avatar Sep 01 '18 16:09 25shady

image

cmd say this but i have the same error

import speech_recognition as sr

ModuleNotFoundError: No module named 'speech_recognition'

gabbsoares avatar Sep 05 '18 11:09 gabbsoares

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

25shady avatar Sep 05 '18 16:09 25shady

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:

import speech_recognition as sr
sr.__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:

!pip3 install --upgrade speechrecognition
import speech_recognition as sr
sr.__version__

And it was working for me...

sugatoray avatar Sep 16 '18 18:09 sugatoray

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:

  1. go to C:\Python\Lib\site-packages
  2. Copy files :1: speech_recognition 2: SpeechRecognition-3.8.1.dist-info
  3. Paste it in your C:\anaconda\Lib\site-packages

This will fix the problem.

staRk22 avatar Nov 16 '18 11:11 staRk22

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:

  1. go to C:\Python\Lib\site-packages
  2. Copy files :1: speech_recognition 2: SpeechRecognition-3.8.1.dist-info
  3. Paste it in your C:\anaconda\Lib\site-packages

This will fix the problem.

Thanks @staRk22 ...your solution works!!

Nahidahmed avatar Feb 25 '19 02:02 Nahidahmed

@staRk22 where is this anaconda folder... i dont have...

bishesh23 avatar Mar 11 '19 14:03 bishesh23

Try sudo pip3 install --upgrade speechrecognition thanks, work for me.

ramiresnas avatar Apr 02 '19 18:04 ramiresnas

verify if you don't have a two version python installed ex: 3.7.3 (x64) and 3.7.4 (x32) delete 3.7.3 and it is worked ok next

alexmursa2013 avatar Jul 19 '19 21:07 alexmursa2013

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 >

Screenshot from 2019-08-22 13-22-08 3-f3e2f800-c4df-11e9-993a-f84730e16d12.png)

-> install Package

uzzalmondal131 avatar Aug 22 '19 07:08 uzzalmondal131

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

This worked for me. Thanks.

rsmahajan avatar Sep 17 '19 02:09 rsmahajan

I have the same problem, but nothing helped me. I tried to upgrade the speechrecognition and copy/paste the files to anaconda path - to no avail... I need your advice people, thank you in advance!

ghost avatar Dec 28 '19 21:12 ghost

I have the same problem Here is my solution

  1. I downloaded the file into right directory of anaconda. but still, it was not working. (If you have wrong directory path set it up at anaconda/lib/site_packages)
  2. I went into the folder then I found out it is not speechrecogniton instead it is speech_recogniton. so I changed the name and it worked for me

ayushboss1 avatar May 07 '20 08:05 ayushboss1

Hi @rajnishcoder,

Can you post the following information?

1. The path that `speech_recognition` has been installed to.

2. The output of `python -c "import sys; print(sys.path)"`.

3. How you installed `speech_recognition` (e.g., using `pip` vs. using `pip3`).

I would also make sure first of all that it's installed with pip3 rather than pip, since IIRC that would default to installing for Python 2.

To add on this, a general solution to install packages on a specific Python version, if they are installed:

  • Calling pip [package_to_install] is shortcut for the pip script, through default python version: it is the same as python -m pip install [package_to_install].
  • It can be tricky to not mess up pip when managing various Python versions, so then pip and even pip3 do not install where you'd like it to be.
  • In case python version aliases are properly set up, you can install easily to the Python version just by calling the un-shortened command. Say we want to install packages to Python 3.7, despite python calling a 2.7 build and python3 calling a 3.8 build. Instead of calling pip or pip3 shortcuts, which most likely are associated to those last ones, use the whole:
python3.7 -m pip install --upgrade [package]

pnmartinez avatar May 14 '20 07:05 pnmartinez

import speech_recognition as sr

this resolve my problem when I look into python site packages I realise the name os the package is different and I tried Above one and it worked

sscswapnil avatar May 23 '20 16:05 sscswapnil

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 to import 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.

ArcticLilacFox avatar Aug 17 '20 14:08 ArcticLilacFox

Traceback (most recent call last): File "jarvis_main_code.py", line 48, in Listen() File "jarvis_main_code.py", line 34, in Listen r = sr.Recognition() AttributeError: module 'speech_recognition' has no attribute 'Recognition'

Rushil-Sharma avatar Aug 21 '20 10:08 Rushil-Sharma

File "jarvis_main_code.py", line 49, in Listen() File "jarvis_main_code.py", line 35, in Listen with sr.Microphone as source : AttributeError: enter

Rushil-Sharma avatar Aug 21 '20 11:08 Rushil-Sharma

I'm keep getting these errors below😑 C:\python programs\Jarvis>python -u "c:\python programs\Jarvis\jarvis.py" Traceback (most recent call last): File "c:\python programs\Jarvis\jarvis.py", line 2, in import SpeechRecognition ModuleNotFoundError: No module named 'SpeechRecognition' Please help me to resolve my problem.

shaliniverma132 avatar Sep 25 '20 09:09 shaliniverma132

what i did is installed python again but if it still doesnt work then do not use it

Rushil-Sharma avatar Sep 26 '20 03:09 Rushil-Sharma

I'm getting ModuleNotFoundError: No module named 'speech_recognition' Screenshot (4) Screenshot (5)

SpeechRecognition is installed but I could'nt find speechrecognition file. Pleassss help me

JaysreeeRoyal avatar Nov 06 '20 11:11 JaysreeeRoyal

you have to go to where it is installed and check if it is running there without an error or you must have changed the code

Rushil-Sharma avatar Nov 10 '20 10:11 Rushil-Sharma

try pip3 install --upgrade speechrecognition

I used repl.it and I have to manually install the package, and that made it work...

ghost avatar Nov 17 '20 13:11 ghost

I too, am facing the same problem. :(

SebS-Dev avatar Apr 11 '21 11:04 SebS-Dev

Speech recognition is already satisfied?

SebS-Dev avatar Apr 11 '21 11:04 SebS-Dev