Errors on PyAudio on Visual studio code Python - python

Hello you see I am creating a voice assistant and I have an error on PyAudio I don't know how to fix that I am using The speech recognition module from pip
error:
[Running] python -u "c:\Users\visha\Desktop\Steel\steel.py"
Computer: Good Evening!
Computer: Hello My name is Steel your AI Friendin!
Computer: How may I help you?
Traceback (most recent call last):
File "C:\Users\visha\AppData\Local\Programs\Python\Python37\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\visha\Desktop\Steel\steel.py", line 63, in <module>
query = myCommand()
File "c:\Users\visha\Desktop\Steel\steel.py", line 44, in myCommand
with sr.Microphone() as source:
File "C:\Users\visha\AppData\Local\Programs\Python\Python37\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\visha\AppData\Local\Programs\Python\Python37\lib\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation

This worked for me:
To install pyaudio on Windows Visual Studio Python
Wheel files are here https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
Download correct wheel file for your version of Python and Windows
In the Visual Studio Packages (PyPl) window, enter the full pathname of your download
Select the Run command pip install line (first one displayed)

Related

Pyaudio is not recognized by python, what to do?

Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
File "C:\Python39\lib\site-packages\pyaudio.py", line 116, in <module>
import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python39\yagmail.py", line 2, in <module>
import yagmail
File "C:\Python39\yagmail.py", line 5, in <module>
with sr.Microphone() as source:
File "C:\Python39\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Python39\lib\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
I have installed Pyaudio for atleast a dozen times but it doesn`t work, my laptop is windows 10 64 bit, but why is port audio appeared in the error, I mean portaudio is related to mac, right? Why does it ask about portaudio? And also I have installed and uninstalled the pyaudio a dozen times at least. I installed it using pip, pipwin and what not.. and it's not only this one yagmail project, voice recognition and pyaudio related every project is showing the same error.
Please, help.
Method 1:
First:
pip install pipwin
then:
pipwin install pyaudio
Method 2:
First:
sudo apt-get install portaudio19-dev
Then:
git clone https://people.csail.mit.edu/hubert/git/pyaudio.git
Then:
python setup.py install //As you are on Windows

Pyaudio doesn't work when I try to run the code on windows

This is my code but when I start to code I get error. I installed pip and the other function but error occurs
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak Anything: ")
audio = r.listen(source)
try:
text=r.recognize_google(audio)
print("You said:()".format(text))
except:
print("Sorry could not recognize what you said")
And also this is my error. I tried a lot of solution but nothings work.
Traceback (most recent call last):
File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\lib\site-packages\speech_recognition_init_.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Asus\PycharmProjects\pythonProject2\main.py", line 3, in
with sr.Microphone() as source:
File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\lib\site-packages\speech_recognition_init_.py", line 79, in init
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\Asus\PycharmProjects\pythonProject2\venv\lib\site-packages\speech_recognition_init_.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
As you mention your python version is 3.9 you can find associate wheel file from here
Let me give you example from image as you can see my python version is 3.7 so i will download PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl which contains only python 3.7
cp37m‑win_amd64 which means python 3.7 with 64 bit and verify from image
Now i will download that file and give full path where i have downloaded and use as
pip install path-to-wheel-file
so now you have to do for python 3.9 and check it is 32 bit or 64 bit and download wheel file and install pyaudio

ImportError: Error occured while running `from pyglet.gl import *` while handling exception :Library "GL" not found

My python code for a reinforcement task cannot render when I run it in docker. I tried installing GL when I got the import error but it still gives me the same error. Is there ay other way to fix this without messing with package managers?
Error message:
/usr/local/lib/python3.7/site-packages/gym/logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Episode 0
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/rendering.py", line 33, in <module>
from pyglet.gl import *
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/__init__.py", line 95, in <module>
from pyglet.gl.lib import GLException
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/lib.py", line 149, in <module>
from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX
File "/usr/local/lib/python3.7/site-packages/pyglet/gl/lib_glx.py", line 45, in <module>
gl_lib = pyglet.lib.load_library('GL')
File "/usr/local/lib/python3.7/site-packages/pyglet/lib.py", line 164, in load_library
raise ImportError('Library "%s" not found.' % names[0])
ImportError: Library "GL" not found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "if.py", line 106, in <module>
env.render()
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/environment.py", line 501, in render
self._init_render()
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/environment.py", line 494, in
_init_render
from .rendering import Viewer
File "/usr/local/lib/python3.7/site-packages/lbforaging/foraging/rendering.py", line 41, in <module>
"""
ImportError:
Error occured while running `from pyglet.gl import *`
HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'.
If you're running on a server, you may need a virtual frame buffer; something like this should work:
'xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>'
pip3 install GL says requirement already satisfied and gives the same error "GL not found"
and pip3 install OpenGL gives:
ERROR: Could not find a version that satisfies the requirement OpenGL
ERROR: No matching distribution found for OpenGL
You need an older version of pyglet; Installing it via pip should do the trick:
pip install pyglet==1.5.11
Further discussion here:
https://github.com/openai/gym/issues/2101

pip - unable to find vcvarsall.bat

From last week, I tried to solve this but couldn't fix this error. While, I tried to install, following error comes:
C:\Users\#######>pip install pyproj
Collecting pyproj
Using cached pyproj-1.9.5.1.tar.gz
Complete output from command python setup.py egg_info:
using bundled proj4..
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\H~1\AppData\Local\Temp\pip-build-e4o66o1z\pyproj\setup.py", line 72, in <module>
objects = cc.compile(['nad2bin.c', 'src/pj_malloc.c'])
File "C:\Users\######\Anaconda3\lib\distutils\_msvccompiler.py", line 317, in compile
self.initialize()
File "C:\Users\########\Anaconda3\lib\distutils\_msvccompiler.py", line 210, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\Users\#######\Anaconda3\lib\distutils\_msvccompiler.py", line 85, in _get_vc_env
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\H~1\AppData\Local\Temp\pip-build-e4o66o1z\pyproj\
I couldn't proceed ahead without fixing this error. I have installed Microsoft Visual C++.
Installing some Python packages under Windows can be troublesome. You can find a precompiled package at
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj
Just download the .whl file that suits your Python version then install it using
pip install <filename>.whl

matplotlib issues installing on windows

I'm trying to install matplotlib on windows using easy-install and also I tried pip, but I'm getting the error below, how can I fix this
error: Setup script exited with error: Could not initialize compiler instance: do you have Visual Studio installed? If you are trying to build with mingw, please use python setup.py
build -c mingw32 instead. If you have Visual Studio installed, check it is
correctly installed, and the right version (VS 2008 for python 2.6, VS 2003 for
2.5, etc...). Original exception was: Unable to find vcvarsall.bat, and the Compiler class was MSVCCompiler
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Python26\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "C:\Python26\lib\multiprocessing\util.py", line 270, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
File "C:\Python26\lib\atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "C:\Python26\lib\multiprocessing\util.py", line 270, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
C:\Python26\Scripts>
Compiling C extensions on Windows requires VisualStudio Express in the most cases and will be far from easy. Instead you can download the binary package for your Python version to a local directory and install with easy_install like so:
easy_install "C:\path_to_local_binary_dir\matplotlib-1.3.1-win-xxx.exe"
(replace with full path/filename). This will not show up in Add/Remove programs and also works for virtual envs.

Categories