inclusion-international / speech-jokey

A speech synthesis software with integration of several TTS APIs, SSML support and optimizations for users with motor impairment. (course ASSIST HEIDI WS2023 and SS2024)
MIT License
1 stars 0 forks source link

Pyaudio: broken dependencies on Linux when using poetry install #7

Closed HackXIt closed 4 months ago

HackXIt commented 4 months ago

When running poetry install on a fresh clone of the project (specifically in branch develop_ui_fixes), I got the following error:

Using version ^0.2.14 for pyaudio

Updating dependencies
Resolving dependencies... (0.4s)

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

   • Installing pyaudio (0.2.14): Failed

  CalledProcessError

  Command '['/home/rini-debian/git-stash/speech-jokey/.venv/bin/python', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/home/rini-debian/git-stash/speech-jokey/.venv', '--no-deps', '/home/rini-debian/.cache/pypoetry/artifacts/55/c9/e0/71c3bad3da5be24043605675ca00b16673c99b880cf946013edbbfb226/PyAudio-0.2.14.tar.gz']' returned non-zero exit status 1.

  at /usr/lib/python3.11/subprocess.py:571 in run
       567│             # We don't call process.wait() as .__exit__ does that for us.
       568│             raise
       569│         retcode = process.poll()
       570│         if check and retcode:
    →  571│             raise CalledProcessError(retcode, process.args,
       572│                                      output=stdout, stderr=stderr)
       573│     return CompletedProcess(process.args, retcode, stdout, stderr)
       574│ 
       575│ 

The following error occurred when trying to handle this error:

  EnvCommandError

  Command ['/home/rini-debian/git-stash/speech-jokey/.venv/bin/python', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/home/rini-debian/git-stash/speech-jokey/.venv', '--no-deps', '/home/rini-debian/.cache/pypoetry/artifacts/55/c9/e0/71c3bad3da5be24043605675ca00b16673c99b880cf946013edbbfb226/PyAudio-0.2.14.tar.gz'] errored with the following return code 1, and output: 
  Processing /home/rini-debian/.cache/pypoetry/artifacts/55/c9/e0/71c3bad3da5be24043605675ca00b16673c99b880cf946013edbbfb226/PyAudio-0.2.14.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Building wheels for collected packages: PyAudio
    Building wheel for PyAudio (pyproject.toml): started
    Building wheel for PyAudio (pyproject.toml): finished with status 'error'
    error: subprocess-exited-with-error

    × Building wheel for PyAudio (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [18 lines of output]
        running bdist_wheel
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-cpython-311
        creating build/lib.linux-x86_64-cpython-311/pyaudio
        copying src/pyaudio/__init__.py -> build/lib.linux-x86_64-cpython-311/pyaudio
        running build_ext
        building 'pyaudio._portaudio' extension
        creating build/temp.linux-x86_64-cpython-311
        creating build/temp.linux-x86_64-cpython-311/src
        creating build/temp.linux-x86_64-cpython-311/src/pyaudio
        x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/include -I/usr/include -I/home/rini-debian/git-stash/speech-jokey/.venv/include -I/usr/include/python3.11 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-cpython-311/src/pyaudio/device_api.o
        src/pyaudio/device_api.c:9:10: fatal error: portaudio.h: No such file or directory
            9 | #include "portaudio.h"
              |          ^~~~~~~~~~~~~
        compilation terminated.
        error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    ERROR: Failed building wheel for PyAudio
  Failed to build PyAudio
  ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects

  at /usr/lib/python3/dist-packages/poetry/utils/env.py:1540 in _run
      1536│                 output = subprocess.check_output(
      1537│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
      1538│                 )
      1539│         except CalledProcessError as e:
    → 1540│             raise EnvCommandError(e, input=input_)
      1541│ 
      1542│         return decode(output)
      1543│ 
      1544│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

The following error occurred when trying to handle this error:

  PoetryException

  Failed to install /home/rini-debian/.cache/pypoetry/artifacts/55/c9/e0/71c3bad3da5be24043605675ca00b16673c99b880cf946013edbbfb226/PyAudio-0.2.14.tar.gz

  at /usr/lib/python3/dist-packages/poetry/utils/pip.py:58 in pip_install
       54│ 
       55│     try:
       56│         return environment.run_pip(*args)
       57│     except EnvCommandError as e:
    →  58│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
       59│
HackXIt commented 4 months ago

This is due to the fact, that when pyaudio is installed via poetry, it does actually not install the required library dependencies of this package.

pyaudio depends on portaudio19 and on linux the installation of that library is required manually: sudo apt install portaudio19-dev (since we're not installing it as a system package, where certain install scripts would pull the dependency automatically)

@IsabellaReiher You should include that information somewhere in the README.

Once that library is installed, the package can successfully be installed using poetry.

For windows, it should not be a problem, from what I've gathered on the package's homepage.