1
$\begingroup$

I successfully compiled and installed ROS2 on Arch Linux. Everything is working fine (surprisingly!). As I initialized rosdep I got this error:

➜  ~ sudo rosdep init
[sudo] password di enf: 
Traceback (most recent call last):
  File "/usr/bin/rosdep", line 33, in <module>
    sys.exit(load_entry_point('rosdep==0.22.2', 'console_scripts', 'rosdep')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/rosdep", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.11/site-packages/rosdep2/__init__.py", line 40, in <module>
    from .installers import InstallerContext, Installer, \
  File "/usr/lib/python3.11/site-packages/rosdep2/installers.py", line 36, in <module>
    from rospkg.os_detect import OsDetect
  File "/usr/lib/python3.11/site-packages/rospkg/os_detect.py", line 42, in <module>
    import distro
ModuleNotFoundError: No module named 'distro'

Under any circumstance, installing the pip module distro would have been enough: pip install distro --break-system-packages

As a proof I ran:

➜  ~ python                     
Python 3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distro
>>> 

which gave me no error, and also:

➜  ~ pip list | grep distro
distro                               1.9.0
rosdistro                            0.9.0

Can anybody help me finding out what the error is? Thanks for reading

$\endgroup$

1 Answer 1

1
$\begingroup$

I fixed that issue by modifying the file /usr/lib/python3.11/site-packages/rospkg/os_detect.py, by importing platform as distro, i.e. the new imports of that file became:

from __future__ import absolute_import
from __future__ import print_function

import codecs
# to be removed after Ubuntu Xenial is out of support
import sys
# if sys.version_info >= (3, 8):
#     import distro
# else:
#     import platform as distro
import platform as distro
import locale
import os
import platform
import subprocess

Then I got this new error

  File "/usr/lib/python3.11/site-packages/rosdep2/lookup.py", line 33, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

and then many similar issues and solved them by installing the dependencies manually:

paru -S python-yaml python-jaraco.text python-jaraco.functools python-jaraco.context python-more-itertools python-platformdirs python-packaging python-distro python-dateutil python-validate-pyproject python-tomli python-ordered-set python-six python-fastjsonschema python-autocommand python-typing-extensions

... and it finally worked!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.