Python3.8 (Ubuntu 19.10) 中的 pip 问题

Problem with pip in Python3.8 (Ubuntu 19.10)

当我下载Ubuntu 19.10,并使用pip安装python 3.8时,我遇到了这个问题。 我安装了一些模块,没问题。但是尝试 install Kivy/PyoAudio/PyGame (也许它不是完整列表)是一个崩溃。我在终端中可以看到:ERROR: Command errored out with exit status 1.

如果有人知道如何解决这个问题,请写下我应该怎么做。

PyAudio 示例:

ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_wk29gwp/pyaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_wk29gwp/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-ybexxyha/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-_wk29gwp/pyaudio/
    Complete output (16 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    copying src/pyaudio.py -> build/lib.linux-x86_64-3.8
    running build_ext
    building '_portaudio' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.8 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.8/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory
       29 | #include "portaudio.h"
          |          ^~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_wk29gwp/pyaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_wk29gwp/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-ybexxyha/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

PyGame 示例:

ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cthrw5_o/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cthrw5_o/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-cthrw5_o/pygame/pip-egg-info
         cwd: /tmp/pip-install-cthrw5_o/pygame/
    Complete output (12 lines):


    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
    Using UNIX configuration...

    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found
    /bin/sh: 1: sdl-config: not found

    Hunting dependencies...
    WARNING: "sdl-config" failed!
    Unable to run "sdl-config". Please make sure a development version of SDL is installed.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.`   

它需要在您的系统上安装 libsdl 库开发版本。更多信息请见 https://wiki.libsdl.org/Installation

但是使用这个命令似乎应该可以工作

sudo apt-get install libsdl2-2.0

Debian-based systems (including Ubuntu) can simply do "sudo apt-get install libsdl2-2.0" to get the library installed system-wide, and all sorts of other useful dependencies, too.

而且看起来 portaudio19-dev 也是这个案例所必需的(来自您发布的堆栈跟踪)。

sudo apt-get install portaudio19-dev