Pyaudio seems to want to build an avx2 version

Good day,

So I’m trying to install pyaudio the old fashioned way. I compiled and installed portaudio without much difficulty, but sudo pip3 install pyaudio ends with:

    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -Wa,-mbranches-within-32B-boundaries -fPIC -fPIC -g -O3 -feliminate-unused-debug-types -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=32 -Wformat -Wformat-security -m64 -fasynchronous-unwind-tables -Wp,-D_REENTRANT -ftree-loop-distribute-patterns -Wl,-z -Wl,now -Wl,-z -Wl,relro -fno-semantic-interposition -ffat-lto-objects -fno-trapping-math -Wl,-sort-common -Wl,--enable-new-dtags -mtune=skylake -Wa,-mbranches-within-32B-boundaries -fPIC -fPIC -fPIC -I/usr/include/python3.8 -c -march=skylake-avx512 -O3 -fno-semantic-interposition -ffat-lto-objects -flto=4 -mprefer-vector-width=512 src/_portaudiomodule.c -o build/temp.linux-x86_64-3.8/src/_portaudiomodule.o.avx512
    <stdin>:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    /usr/bin/ld: cannot find -lportaudio-avx2
    collect2: error: ld returned 1 exit status
    <stdin>:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    /usr/bin/ld: cannot find -lportaudio-avx512
    collect2: error: ld returned 1 exit status
    gcc -pthread -shared -Wa,-mbranches-within-32B-boundaries -Wl,--build-id=sha1 -Wl,--build-id=sha1 build/temp.linux-x86_64-3.8/src/_portaudiomodule.o -lportaudio -o build/lib.linux-x86_64-3.8/_portaudio.cpython-38-x86_64-linux-gnu.so
    /usr/bin/ld: cannot find -lportaudio
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3fako3k6/pyaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3fako3k6/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-l4e9upg9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/pyaudio Check the logs for full command output.

I notice that it’s building something with --march=skylake-avx2 (and this machine is no Xeon). I’ve unset CFLAGS and tried setting lesser CFLAGS but it seems to end up here. I was just hoping to build a non-avx2 version of this (or figure out the incantation to build a avx2 version of portaudio to get this up and running).

    /usr/bin/ld: cannot find -lportaudio-avx2
    /usr/bin/ld: cannot find -lportaudio-avx512
    /usr/bin/ld: cannot find -lportaudio

While you may have compiled portaudio, it is not searching the path that it’s installed in and cannot find it. Ignore the -avx etc, it cannot find -lportaudio (which is the standard version you would have compiled) and that is your problem.

Python is patched that it would search for those additional libs, but it shouldn’t be fatal for the avx libraries to not be there. It is fatal having no library to link against though, which is the case here.

Thank you!

I couldn’t get it happy with portaudio in /usr/local so I ended up installing a copy in /usr and pip3 happily built pyaudio without issue.