rtmidi-python 的 PIP 构建轮失败(subprocess-exited-with-error 和 legacy-install-failure)

PIP failed building wheel for rtmidi-python (subprocess-exited-with-error and legacy-install-failure)

rtmidi-python 的 PIP 构建轮失败(子进程退出并出现错误和遗留安装失败)

大家好,我在 Raspberry Pi 4B 运行 Raspbian 11.

上安装 rtmidi-python 时遇到 pip 问题

构建轮仅针对该包一直失败,我收到两个错误:subprocess-exited-with-error 和 legacy-install-failure。

这是命令 pip install rtmidi-python :

的输出
pi@raspberrypi:~ $ pip install rtmidi-python
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting rtmidi-python
  Using cached rtmidi-python-0.2.2.tar.gz (54 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: rtmidi-python
  Building wheel for rtmidi-python (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [164 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'rtmidi_python' extension
      creating build
      creating build/temp.linux-armv7l-3.9
      creating build/temp.linux-armv7l-3.9/RtMidi
      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -D__LINUX_ALSA__ -I/usr/include/python3.9 -c RtMidi/RtMidi.cpp -o build/temp.linux-armv7l-3.9/RtMidi/RtMidi.o
      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -D__LINUX_ALSA__ -I/usr/include/python3.9 -c rtmidi_python.cpp -o build/temp.linux-armv7l-3.9/rtmidi_python.o
      rtmidi_python.cpp: In function ‘PyObject* PyInit_rtmidi_python()’:
      rtmidi_python.cpp:2932:39: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
       2932 |   __pyx_type_13rtmidi_python_MidiBase.tp_print = 0;
            |                                       ^~~~~~~~
      rtmidi_python.cpp:2941:38: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
       2941 |   __pyx_type_13rtmidi_python_MidiOut.tp_print = 0;
            |                                      ^~~~~~~~
      [...]
      rtmidi_python.cpp:3110:59: note: in expansion of macro ‘PyUnicode_GET_SIZE’
       3110 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
            |                                                           ^~~~~~~~~~~~~~~~~~
      /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
        446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
            |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
      error: command '/usr/bin/arm-linux-gnueabihf-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 rtmidi-python
  Running setup.py clean for rtmidi-python
Failed to build rtmidi-python
Installing collected packages: rtmidi-python
  Running setup.py install for rtmidi-python ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for rtmidi-python did not run successfully.
  │ exit code: 1
  ╰─> [166 lines of output]
      running install
      /home/pi/.local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      building 'rtmidi_python' extension
      creating build
      creating build/temp.linux-armv7l-3.9
      creating build/temp.linux-armv7l-3.9/RtMidi
      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -D__LINUX_ALSA__ -I/usr/include/python3.9 -c RtMidi/RtMidi.cpp -o build/temp.linux-armv7l-3.9/RtMidi/RtMidi.o
      arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -D__LINUX_ALSA__ -I/usr/include/python3.9 -c rtmidi_python.cpp -o build/temp.linux-armv7l-3.9/rtmidi_python.o
      rtmidi_python.cpp: In function ‘PyObject* PyInit_rtmidi_python()’:
      rtmidi_python.cpp:2932:39: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
       2932 |   __pyx_type_13rtmidi_python_MidiBase.tp_print = 0;
            |                                       ^~~~~~~~
      rtmidi_python.cpp:2941:38: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
       2941 |   __pyx_type_13rtmidi_python_MidiOut.tp_print = 0;
            |                                      ^~~~~~~~
      [...]
      /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
        446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
            |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
      error: command '/usr/bin/arm-linux-gnueabihf-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: legacy-install-failure

× Encountered error while trying to install package.
╰─> rtmidi-python

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Pip (22.0.4) 和 Python (3.9.2) 是最新的。

我试图从 PyPI (https://pypi.org/project/rtmidi-python/#files) 手动下载包以使用 python setup.py install 安装它,但它似乎没有安装任何东西: 这是输出:

pi@raspberrypi:~/Downloads/rtmidi-python-0.2.2 $ sudo python setup.py install
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/rtmidi_python-0.2.2.egg-info
Writing /usr/local/lib/python2.7/dist-packages/rtmidi_python-0.2.2.egg-info

对于某些人来说,这可能是 setup.py 的问题,但我不知道更多。 我一直在大量论坛上寻找解决方案,但没有成功。将不胜感激。

谢谢大家

tp_print 方法已从 Python 3.8 中的 API 中删除。错误“'PyTypeObject' {aka 'struct _typeobject'} 没有名为 'tp_print' 的成员”意味着该代码适用于 Python <= 3.8 .降级到 Python 3.8 并重试。

让我们看看rtmidi-pythonhttps://pypi.org/project/rtmidi-python/#history . Currently the only released version is 0.2.2。该版本于 2014 年 2 月 5 日发布。它看起来太旧了,我不确定它是否可以与 Python 3 一起使用。尝试 Python 3.8,然后 Python 2.7.