记录个ros2用colcon build出现的小错误:ModuleNotFoundError: No module named ‘catkin_pkg‘

ubuntu20.4中ros2版本,colcon build编译报错如下:

Starting >>> fishbot_navigation2
--- stderr: fishbot_navigation2                         
Traceback (most recent call last):
  File "/opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 21, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:94 (message):
  execute_process(/home/ros2/miniconda3/bin/python3
  /opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /home/ros2/code/fishbot_ws/src/fishbot_navigation2/package.xml
  /home/ros2/code/fishbot_ws/build/fishbot_navigation2/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  /opt/ros/foxy/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:34 (ament_lint_auto_find_test_dependencies)


---
Failed   <<< fishbot_navigation2 [0.29s, exited with code 1]
                                
Summary: 0 packages finished [0.42s]
  1 package failed: fishbot_navigation2
  1 package had stderr output: fishbot_navigation2

解决方案如下:

pip3 install catkin_pkg

或者

pip install catkin_pkg
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ModuleNotFoundError: No module named 'catkin_pkg'是一个Python错误提示,它意味着在你的Python环境中没有找到名为'catkin_pkg'的模块。这个错误通常出现在使用ROS(机器人操作系统)的时候,因为ROS使用了catkin构建系统。 要解决这个问题,你可以按照以下步骤进行操作: 1. 确保你已经安装了catkin_pkg模块。你可以使用pip或者apt命令进行安装。在Python2环境中,可以使用以下命令安装:sudo apt install python-catkin-pkg,在Python3环境中,可以使用以下命令安装:sudo apt install python3-catkin-pkg。如果已经安装了该模块,请确保它是最新的版本。 2. 确保catkin_pkg模块在PYTHONPATH环境变量中。你可以使用以下命令来检查PYTHONPATH环境变量的值:echo $PYTHONPATH。如果catkin_pkg模块不在其中,你可以使用以下命令将其添加到PYTHONPATH中: export PYTHONPATH=$PYTHONPATH:/path/to/catkin_pkg 注意替换"/path/to/catkin_pkg"为catkin_pkg模块的实际路径。 如果你已经按照上述步骤操作但仍然遇到问题,你可能需要检查你的ROS安装是否正确,并确保所有依赖项都已正确安装和配置。 总结起来,当出现ModuleNotFoundError: No module named 'catkin_pkg'错误时,你应该首先确保已安装并正确配置了catkin_pkg模块,然后查看PYTHONPATH环境变量是否包含该模块的路径。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [ROS Kinetic创建Python3工作区出现“No module namedcatkin_pkg‘”解决方案](https://blog.csdn.net/qq_35699473/article/details/108808589)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [colcon build出现报错ModuleNotFoundError: No module namedcatkin_pkg](https://blog.csdn.net/m0_64396620/article/details/128753629)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值