Search code examples
pythonpipraspbianpypi

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


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

Hello everyone, I'm facing an issue with pip while installing rtmidi-python on my Raspberry Pi 4B running Raspbian 11.

The building wheel keeps failing for that package only and I get two errors: subprocess-exited-with-error and legacy-install-failure.

Here's the output for the command 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) and Python (3.9.2) are up to date.

I tried to manually download the package from PyPI (https://pypi.org/project/rtmidi-python/#files) to install it with python setup.py install but it does not seem to install anything : Here's the output:

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

For some, that might be a problem with setup.py but I don't know much more. I've been looking for solutions on tons of forums without success. Your help would be appreciated.

Thank you all.


Solution

  • The tp_print method was removed from the API in Python 3.8. Error "'PyTypeObject' {aka 'struct _typeobject'} has no member named 'tp_print'" means that the code is intended for Python <= 3.8. Downgrade to Python 3.8 and try again.

    Let's look at rtmidi-python: https://pypi.org/project/rtmidi-python/#history . Currently the only released version is 0.2.2. The version was released at Feb 5, 2014. It looks too old, I'm not sure it could work with Python 3 at all. Try Python 3.8 and then Python 2.7.