Как исправить ошибку rosdep: Rosdep experienced an error: 'list' object has no attribute 'encode'

Проблема

При выполнении rosdep update вы получаете следующую ошибку:

rosdep_output.txt
reading in sources list data from /opt/openrobots/etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Add distro "ardent"

ERROR: Rosdep experienced an error: 'list' object has no attribute 'encode'
Please go to the rosdep page [1] and file a bug report with the stack trace below.
[1] : http://www.ros.org/wiki/rosdep

rosdep version: 0.10.30

Traceback (most recent call last):
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/main.py", line 126, in rosdep_main
    exit_code = _rosdep_main(args)
                ^^^^^^^^^^^^^^^^^^
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/main.py", line 286, in _rosdep_main
    return _no_args_handler(command, parser, options, args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/main.py", line 294, in _no_args_handler
    return command_handlers[command](options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/main.py", line 467, in command_update
    update_sources_list(success_handler=update_success_handler,
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/sources_list.py", line 438, in update_sources_list
    retval.append((rds, write_cache_file(sources_cache_dir, dist['distribution'], rosdep_data)))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/sources_list.py", line 493, in write_cache_file
    key_hash = compute_filename_hash(filename_key)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/openrobots/lib/python3.12/site-packages/rosdep2/sources_list.py", line 479, in compute_filename_hash
    sha_hash.update(filename_key.encode())
                    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'encode'

Решение

Эта проблема возникает, потому что вы используете старую и устаревшую версию rosdep — возможно, поскольку вы установили rosdep 0.10.30 из репозитория robotpkg. Чтобы исправить эту проблему, вам нужно обновить rosdep до последней версии:

install_rosdep.sh
sudo apt install python3-rosdep

После этого проверьте, используется ли новая версия. Если нет, вам может потребоваться удалить старую версию.

После обновления rosdep вы можете снова запустить rosdep update, и ошибка должна быть устранена.


Check out similar posts by category: ROS Robotics