Problem with installation of python-rtmidi on ubuntu 22.04 LTS

Hi,

On ubuntu 22.04, after having install python3-dev, it not possible to install python-rtmidi, the message of error is the following:

===========================================================================
Collecting python-rtmidi
Downloading python-rtmidi-1.4.9.tar.gz (251 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 251.2/251.2 KB 6.5 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status ‘error’
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
Traceback (most recent call last):
File “”, line 2, in
File “”, line 34, in
File “/tmp/pip-install-w3xmyiky/python-rtmidi_24d2f6537cf54b95964f808a3e6d8b3d/setup.py”, line 153, in
check_for_jack(define_macros, libraries)
File “/tmp/pip-install-w3xmyiky/python-rtmidi_24d2f6537cf54b95964f808a3e6d8b3d/setup.py”, line 44, in check_for_jack
res = subprocess.check_output([‘pkg-config’, ‘–modversion’, ‘jack’])
File “/usr/lib/python3.10/subprocess.py”, line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File “/usr/lib/python3.10/subprocess.py”, line 501, in run
with Popen(*popenargs, **kwargs) as process:
File “/usr/lib/python3.10/subprocess.py”, line 969, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.10/subprocess.py”, line 1845, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘pkg-config’
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Process returned with code 1

===========================================================================

Do you know what to do to resolve this problem ?

Sincerely.

Pascal KREZEL

I’m not sure, but maybe try:

sudo apt install pkg-config

It looks like it’s trying to run pkg-config but it’s not installed. Just a guess though!

Thank you, it was a first step. Now I have a problem with jack:

===========================================================================
Collecting python-rtmidi
Downloading python-rtmidi-1.4.9.tar.gz (251 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 251.2/251.2 KB 6.6 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status ‘done’
Building wheels for collected packages: python-rtmidi
Building wheel for python-rtmidi (setup.py): started
Building wheel for python-rtmidi (setup.py): finished with status ‘error’
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [41 lines of output]
Package jack was not found in the pkg-config search path.
Perhaps you should add the directory containing `jack.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘jack’ found
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiconstants.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiutil.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/init.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/version.py → build/lib.linux-x86_64-3.10/rtmidi
running egg_info
writing python_rtmidi.egg-info/PKG-INFO
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing top-level names to python_rtmidi.egg-info/top_level.txt
reading manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files found matching ‘.appveyor.yml’
warning: no previously-included files found matching ‘.travis.yml’
warning: no previously-included files found matching ‘.rst.in’
no previously-included directories found matching ‘ci’
warning: no previously-included files matching ‘pycache’ found under directory '

warning: no previously-included files matching ‘.py[co]’ found under directory '
adding license file ‘LICENSE.txt’
adding license file ‘AUTHORS.rst’
writing manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
running build_ext
building 'rtmidi.rtmidi’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/rtmidi
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
_ -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi.o
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
-D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi/RtMidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi/RtMidi.o
src/rtmidi/RtMidi.cpp:1540:10: fatal error: alsa/asoundlib.h: Aucun fichier ou dossier de ce type
1540 | #include <alsa/asoundlib.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 python-rtmidi
Running setup.py clean for python-rtmidi
Failed to build python-rtmidi
Installing collected packages: python-rtmidi
Running setup.py install for python-rtmidi: started
Running setup.py install for python-rtmidi: finished with status ‘error’
error: subprocess-exited-with-error

× Running setup.py install for python-rtmidi did not run successfully.
│ exit code: 1
╰─> [43 lines of output]
Package jack was not found in the pkg-config search path.
Perhaps you should add the directory containing `jack.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘jack’ found
running install
/usr/lib/python3/dist-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_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiconstants.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiutil.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/init.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/version.py → build/lib.linux-x86_64-3.10/rtmidi
running egg_info
writing python_rtmidi.egg-info/PKG-INFO
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing top-level names to python_rtmidi.egg-info/top_level.txt
reading manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files found matching ‘.appveyor.yml’
warning: no previously-included files found matching ‘.travis.yml’
warning: no previously-included files found matching ‘.rst.in’
no previously-included directories found matching ‘ci’
warning: no previously-included files matching ‘pycache’ found under directory '

warning: no previously-included files matching ‘.py[co]’ found under directory '
adding license file ‘LICENSE.txt’
adding license file ‘AUTHORS.rst’
writing manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
running build_ext
building 'rtmidi.rtmidi’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/rtmidi
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
_ -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi.o
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
-D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi/RtMidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi/RtMidi.o
src/rtmidi/RtMidi.cpp:1540:10: fatal error: alsa/asoundlib.h: Aucun fichier ou dossier de ce type
1540 | #include <alsa/asoundlib.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: legacy-install-failure

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

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

==============================================================================

I tried to install the jack module but I obtained:

==============================================================================
/usr/bin/python3 -m pip install --no-cache-dir --user jack --disable-pip-version-check

Collecting jack
Downloading jack-0.1.0.tar.gz (3.8 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status ‘error’
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File “”, line 2, in
File “”, line 34, in
File “/tmp/pip-install-d6j2glk5/jack_1adf3db6f5cd4de092924ac188ee6b07/setup.py”, line 6, in
from pip.req import parse_requirements
ModuleNotFoundError: No module named ‘pip.req’
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Process returned with code 1

==============================================================================
Do you know what to do to resolve this problem ?

Sincerely.

Pascal KREZEL

try sudo apt-get install libasound2-dev

After having done: sudo apt-get install libasound2-dev
I obtained:

===========================================================================
/usr/bin/python3 -m pip install --no-cache-dir --user python-rtmidi --disable-pip-version-check

Collecting python-rtmidi
Downloading python-rtmidi-1.4.9.tar.gz (251 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 251.2/251.2 KB 1.0 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status ‘done’
Building wheels for collected packages: python-rtmidi
Building wheel for python-rtmidi (setup.py): started
Building wheel for python-rtmidi (setup.py): finished with status ‘error’
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [41 lines of output]
Package jack was not found in the pkg-config search path.
Perhaps you should add the directory containing `jack.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘jack’ found
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/version.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiutil.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiconstants.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/init.py → build/lib.linux-x86_64-3.10/rtmidi
running egg_info
writing python_rtmidi.egg-info/PKG-INFO
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing top-level names to python_rtmidi.egg-info/top_level.txt
reading manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files found matching ‘.appveyor.yml’
warning: no previously-included files found matching ‘.travis.yml’
warning: no previously-included files found matching ‘.rst.in’
no previously-included directories found matching ‘ci’
warning: no previously-included files matching ‘pycache’ found under directory '

warning: no previously-included files matching ‘.py[co]’ found under directory '
adding license file ‘LICENSE.txt’
adding license file ‘AUTHORS.rst’
writing manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
running build_ext
building 'rtmidi.rtmidi’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/rtmidi
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
_ -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi.o
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
-D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi/RtMidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi/RtMidi.o
src/rtmidi/RtMidi.cpp:3010:10: fatal error: jack/jack.h: Aucun fichier ou dossier de ce type
3010 | #include <jack/jack.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 python-rtmidi
Running setup.py clean for python-rtmidi
Failed to build python-rtmidi
Installing collected packages: python-rtmidi
Running setup.py install for python-rtmidi: started
Running setup.py install for python-rtmidi: finished with status ‘error’
error: subprocess-exited-with-error

× Running setup.py install for python-rtmidi did not run successfully.
│ exit code: 1
╰─> [43 lines of output]
Package jack was not found in the pkg-config search path.
Perhaps you should add the directory containing `jack.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘jack’ found
running install
/usr/lib/python3/dist-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_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/version.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiutil.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/midiconstants.py → build/lib.linux-x86_64-3.10/rtmidi
copying rtmidi/init.py → build/lib.linux-x86_64-3.10/rtmidi
running egg_info
writing python_rtmidi.egg-info/PKG-INFO
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing top-level names to python_rtmidi.egg-info/top_level.txt
reading manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files found matching ‘.appveyor.yml’
warning: no previously-included files found matching ‘.travis.yml’
warning: no previously-included files found matching ‘.rst.in’
no previously-included directories found matching ‘ci’
warning: no previously-included files matching ‘pycache’ found under directory '

warning: no previously-included files matching ‘.py[co]’ found under directory '
adding license file ‘LICENSE.txt’
adding license file ‘AUTHORS.rst’
writing manifest file ‘python_rtmidi.egg-info/SOURCES.txt’
running build_ext
building 'rtmidi.rtmidi’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/rtmidi
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
_ -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi.o
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__RTMIDI_SILENCE_WARNINGS
-D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.10 -c src/rtmidi/RtMidi.cpp -o build/temp.linux-x86_64-3.10/src/rtmidi/RtMidi.o
src/rtmidi/RtMidi.cpp:3010:10: fatal error: jack/jack.h: Aucun fichier ou dossier de ce type
3010 | #include <jack/jack.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: legacy-install-failure

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

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

Hi,

I succeeded with: sudo apt-get install libjack-dev.
Now the easy_setup is done.

Pascal

Glad to hear it! I wonder if this is something funny about your setup, or if it’s something that the python-rtmidi people should be fixing

I think that everyone who uses Ubuntu will have the same problem. I will confirm this on another computer on Monday.

In fact, on ubuntu, you must do the 2 following steps to make python-rtmidi works:
sudo apt-get install libasound2-dev
sudo apt-get install libjack-dev

Pascal

Did you need to install pkg-config on the other computer too? If not, maybe it’s covered by the other two installs. I just want to know exactly what’s needed so I can update the documentation

it is installed but I can’t confirm that it is useful.