Pyaudio is not recognized by python, what to do? - python

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

Related

FluidSynth not available using scamp

I have the following boilerplate code
from scamp import *
s = Session()
s.tempo = 120
clarinet = s.new_part("clarinet")
When I run it, I get the error
Traceback (most recent call last):
File "/home/norhther/Descargas/music.py", line 6, in <module>
clarinet = s.new_part("clarinet")
File "/home/norhther/.local/lib/python3.9/site-packages/scamp/instruments.py", line 184, in new_part
instrument.add_soundfont_playback(preset=preset, soundfont=soundfont, num_channels=num_channels,
File "/home/norhther/.local/lib/python3.9/site-packages/scamp/instruments.py", line 984, in add_soundfont_playback
SoundfontPlaybackImplementation(bank_and_preset=preset, soundfont=soundfont, num_channels=num_channels,
File "/home/norhther/.local/lib/python3.9/site-packages/scamp/playback_implementations.py", line 327, in __init__
SoundfontHost(
File "/home/norhther/.local/lib/python3.9/site-packages/scamp/_soundfont_host.py", line 176, in __init__
raise ModuleNotFoundError("FluidSynth not available.")
ModuleNotFoundError: FluidSynth not available.
I installed FluidSynth in my system (Ubuntu) and I can execute it with no problem. I also used pip install pyFluidSynth with pip
Note: This answer predates OP editing the question; The question indeed contained the quoted phrase.
I also used pip install fluidsynth with pip
The fluidsynth package on PyPI was last updated in 2012, and is not what SCAMP depends on for interfacing with FluidSynth. The correct package to be installed is called pyFluidSynth. To install it, run the following command.
pip install pyFluidSynth
You'll also have to uninstall the wrong fluidsynth package.
pip uninstall fluidsynth

ImportError: DLL load failed while importing QtWebEngineWidgets: when running spyder for python

I get this issue when trying to run spyder
C:\ProgramData\Anaconda3\Scripts>spyder
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: DLL load failed while importing QtWebEngineWidgets: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 178, in main
from spyder.app import mainwindow
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 90, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 26, in <module>
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
I have tried https://www.programmersought.com/article/80564836035/ of pip installing PyQtWebEngine and uninstalling PyQt5-stubs
I don't use Spyder, but I ran into this issue and managed to solve it somehow.
I had installed PyQtWebEngine like this: pip install PyQtWebEngine. However, this did not cause the proper Python39\Lib\site-packages\PyQt5\Qt5\bin\Qt5WebEngine.dll file to be created.
The solution:
pip uninstall PyQtWebEngine
pip uninstall PyQtWebEngine-qt5
pip install PyQtWebEngine-qt5
pip install PyQtWebEngine
While the prerequisite that installs the Qt5 tooling does end up installed, it is somehow messed up. Install it manually first ensured everything got placed where it was supposed to be.

Errors on PyAudio on Visual studio code 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)

Using Pip and Importing Packages in Python 3 on Ubuntu

I'm on Lubuntu (a minimal build of Ubuntu). I installed Python 3.6.1 with:
sudo apt-get install python3.6
I want to use Twilio, so I tried this:
pip install twilio
It said pip wasn't recognized, so I ran this, followed by the above again:
sudo apt install python-pip
I fired up Python 3.6 and tried importing it, but that didn't work out:
>>> from twilio.rest import Client
ModuleNotFoundError: No module named 'twilio'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I'm new to python3 (which I want to use for the secrets module), Ubuntu, and twilio, so I'm not really sure what's going on here. I'd think if it was as simple as a module not being found, the stack trace would be much shorter... I'm not sure if the stack trace is so long because maybe Python 3 produces longer ones than 2 did, or Ubuntu is trying to do something weird because both Python 2 and 3 are installed (and perhaps two versions of 3 at that), or if maybe this is the work of twilio?
Try the following to download pip:
wget https://bootstrap.pypa.io/get-pip.py
Then install pip by running:
sudo python3 get-pip.py
Then you can install twilio with pip
sudo pip3 install twilio

pip3 won't install python bindings for VLC

Can't seem to get the Python3 bindings for VLC functioning.
I'm doing pip3 install python_vlc which results in:
Collecting python-vlc
Installing collected packages: python-vlc
Successfully installed python-vlc-1.1.2
So, when I do import vlc it gives me the following error:
>>> import vlc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/vlc.py", line 173, in <module>
dll, plugin_path = find_lib()
File "/usr/local/lib/python3.5/site-packages/vlc.py", line 165, in find_lib
dll = ctypes.CDLL('libvlc.dylib')
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libvlc.dylib, 6): image not found
I tried looking for a solution online, but can't seem to find the cause.
Alright, so I found the problem...
I tried uninstalling python-vlc via pip3 uninstall python-vlc and uninstall the VLC app with AppZapper to completely remove everything. After this I reinstalled it, it worked so I can do import vlc in commandline now.
Update: so after I did that I ran into another issue. I got this error: core libvlc error: No plugins found! Check your VLC installation.
Added the following line to my .bash_profile:
export VLC_PLUGIN_PATH=$VLC_PLUGIN_PATH:/Applications/VLC.app/Contents/MacOS/plugins
which fixed it.

Categories