Rosdep cannot initialise

System spec:

Ubuntu 18.04 ROS Melodic

Python 3.10.2 (when i run python --version)

Jetson Xavier

Description: I was following the official tutorial from ROS wiki on installing ROS Melodic but I having a problem when i tried to init rosdep.

Installation of rosdep was not a problem. the result is as follows:

sudo apt install python-rosdep
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-rosdep is already the newest version (0.21.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

However, the initialisation of rosdep return this:

sudo rosdep init
 Traceback (most recent call last):
  File "/usr/bin/rosdep", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 77, in <module>
    __import__('pkg_resources.extern.packaging.requirements')
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
    from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
  File "/usr/lib/python3/dist-packages/pkg_resources/extern/__init__.py", line 43, in load_module
    __import__(extant)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 943, in <module>
    collections.MutableMapping.register(ParseResults)
AttributeError: module 'collections' has no attribute 'MutableMapping'

Hence, I suspect it is due to python version. I hope I could get a second opinion on this.

I’ve seen cases of this when the /lib/ directory is not empty. Check out this solution and see if it works for you:

https://answers.ros.org/question/343741/trying-to-do-sudo-rosdep-init-and-getting-the-below-error/

Yeah but the problem was indeed the python default version problem. I changed it to python 3 but it was supposed to be python2. I just have to change it back and it works perfectly. Can refer to the replies in this link: rosdep cannot initialise - ROS Answers: Open Source Q&A Forum

1 Like