Linux 上的 PyAudio 编译错误(Python.h:没有这样的文件或目录)

问题描述 投票:0回答:1
(modulos-proyectos) josue@josue-OptiPlex-3010:~/Descargas/portaudio$ pip install pyaudio
Collecting pyaudio
  Using cached PyAudio-0.2.14.tar.gz (47 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pyaudio (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-312
      creating build/lib.linux-x86_64-cpython-312/pyaudio
      copying src/pyaudio/__init__.py -> build/lib.linux-x86_64-cpython-312/pyaudio
      running build_ext
      building 'pyaudio._portaudio' extension
      creating build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312/src
      creating build/temp.linux-x86_64-cpython-312/src/pyaudio
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/include -I/usr/include -I/home/josue/Documentos/PythonUniversalModulos/modulos-proyectos/include -I/usr/include/python3.12 -c src/pyaudio/device_api.c -o build/temp.linux-x86_64-cpython-312/src/pyaudio/device_api.o
      In file included from src/pyaudio/device_api.c:1:
      src/pyaudio/device_api.h:7:10: fatal error: Python.h: No such file or directory
          7 | #include "Python.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

He aprovado de Todo, la pagina oficial y nada

python linux
1个回答
0
投票

对于基于 Ubuntu 或 Debian 的系统,通常可以通过安装 python3-dev 包来解决此问题:

sudo apt-get update
sudo apt-get install python3-dev

对于基于 Red Hat、CentOS 或 Fedora 的系统,您可能需要安装 python3-devel 软件包:

sudo yum install python3-devel  # For CentOS/RHEL

sudo dnf install python3-devel  # For Fedora

安装适当的 Python 开发标头后,尝试使用 pip 再次安装 pyaudio:

pip install pyaudio
© www.soinside.com 2019 - 2024. All rights reserved.