Cannot Install PyAudio, portaudiomodule error - python

Currently trying to install PyAudio on my Surface Pro 7, and am getting this error code when I try to use the prompt pip install PyAudio to install it:
ERROR: Command errored out with exit status 1:
src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
Can someone help explain why this won't work, please? Thanks!

Download a wheel file from https://www.lfd.uci.edu/~gohlke/pythonlibs/ and install via pip install wheelfile.whl. Check your python version before downloading.

This issue means that the PyAudio library has a script with an include statement for the portaudio header file. Include statements in C and similar languages are like Import statements in Python. Because the file doesn't exist, the library can't run.
If PyAudio is installed via pip, PortAudio has to be downloaded separately. Here is the official website with instructions to download.
An alternative would be to use Anaconda to install packages for python. Anaconda will automatically install portaudio, or provide a reason why it can't, in which case, you will have to follow the steps on the website linked earlier.
Also, see this SO Question.

Related

Pip install results in this error " cl.exe' failed with exit code 2 "

I've read all of the other questions on this error and frustratingly enough, none give a solution that works.
If I run pip install sentencepiece in the cmd line, it gives me the following output.
src/sentencepiece/sentencepiece_wrap.cxx(2809): fatal error C1083: Cannot open include file: 'sentencepiece_processor.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
I'm running python 3.10.1 and pip 22.0.3 .
*I have the following Microsoft Visual C++ programs on my windows machine,which I've just done a fresh install of as it was complaining of not having a particular C++ program.
MS VC++
I've even added the .exe file to my PATH variables but still I get the same error.
Am I missing a particular Microsoft program on my pc?
I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing). In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.
Could also just be an error specific to the module and Python version combo you're trying.
From a discussion in the comments:
I have the pyenv-win version manager, so I was able to create venvs and test this for you. With Python 3.10.2, it fails; with Python 3.8.10, it's successful. So, yes, reinstalling does seem to be worthy of your time.
With python3.10
On Windows: First, install vcpkg and install sentencepiece:x64-windows-static
copy the header and lib files from vcpkg/installed/x64-windows-static/include and lib to
C:/Program Files/python310/build/root/include and lib
This should work as the setup.py install expects the library in a ..\build\root\lib directory.
As the C:\Program Files\python310\lib is in the /LIBPATH, the resulting ..\build\root\lib will point to the sentencepiece.lib
If still encounting errors, then set the INCLUDE and LIB environment variables so that the cl.exe , which is called from pip install sentencetransformers finds them.
People having windows+python 3.10 env, here are exact steps to install it via vcpkg.
Other instructions are covered in zweistein's answer.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install sentencepiece:x64-windows-static

error in installing a module or package or something in python

I am trying to install pyaudio module in my terminal for python, and I got this error.
rc/_portaudiomodule.c(29): fatal error C1083: Cannot open include
file: 'portaudio.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\bin\HostX86\x86\cl.exe'
failed with exit status 2
Help me please
If you are targeting native Win32 Python, you will need either MinGW (via Cygwin) or Microsoft Visual Studio
pyaudio compilation docs
Try this
pip install pipwin
pipwin install pyaudio

How to properly install PyAudio for the latest version of Python?

I was using speech_recognition with the latest version of Python (3.9). And for some reason, pip did not (still does not) allow me to install pyaudio.
sample of the error message:
_portaudiomodule.c
c:\program files\python39\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
It has been meaningless for me to look for what portaudio.h does.
Here is the solution. I hope you don't waste your time like I did.
The reason is pip gets the packages from PyPi. And PyPi does not have PyAudio package that supports Python 3.9. This is why, it is useless to try and install pyaudio with pip install pyaudio.
What you should do, instead, is you go to Unofficial Windows Binaries for Python Extension Packages page and download the pip wheel:
last step is to run
pip install [insert pyaudio wheel directory]\pyAudio-0.2.11-cp39-cp39-win_amd64.whl
You should be alright with this.
By the way, this trick works with other packages that you want to run with the latest python version.

'sqlite3.h': No such file or directory

I am attempting to install the pysqlite module for Python 2.7 on my Windows 10 computer. I issued the following command:
pip install pysqlite
The installation ran as usual until it hit an error:
c:\users\xaresys\appdata\local\temp\pip-build-xleoab\pysqlite\src\connection.h(33) : fatal error C1083: Cannot open include file: 'sqlite3.h': No such file or directory
error: command 'C:\Users\xaresys\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
I also tried to install a similar module, pysqlcipher, which hit the same error. Do I need to install anything before installing this? Thanks.
Looks like you are missing Visual C++ binaries which are required to install some packages. Follow instructions here: https://github.com/develersrl/gccwinbinaries

h5py install error failed with exit status 2

I am using Windows 7 and Python 2.7.9. I tried to install h5py with pip, but have the following error:
[c:\users\dell\appdata\local\temp\pip-build-j2msd9\h5py\h5py\api_compat.h(27) : fatal error C1083: cannot open include file:“hdf5.h”: No such file or directory
error: command 'd:\visual studio 2008\VC\BIN\amd64\cl.exe' failed with exit status 2
things I have tried:
Reinstall Visual Studio 2008 compiler
installed some necessary modules such as modHDF5 and numpy
The error you are getting is because you have not installed HDF5, or you have not specified the directory that HDF5 has been installed into.
The simplest thing to do, is to try to install h5py with a modern pip which supports wheels (e.g. run python.exe -m pip install -U pip, and then try reinstalling h5py).
If you want to build from source on Windows, see http://docs.h5py.org/en/latest/build.html#source-installation-on-windows, but I strongly recommend using wheels on Windows (as the person who wrote said CI scripts).
I changed the version of h5py to 2.9.0 and it worked like a charm
Please check what version is installed along with Pre-built package.

Categories