(笔记)ROS2 colcon build报错:ModuleNotFoundError: No module named ‘catkin_pkg‘

 

在使用ROS2时,使用colcon build编译时,报错如下:

复制代码
 1 Starting >>> fishbot_navigation2
 2 --- stderr: fishbot_navigation2                         
 3 Traceback (most recent call last):
 4   File "/opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 21, in <module>
 5     from catkin_pkg.package import parse_package_string
 6 ModuleNotFoundError: No module named 'catkin_pkg'
 7 CMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:94 (message):
 8   execute_process(/home/ros2/miniconda3/bin/python3
 9   /opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
10   /home/ros2/code/fishbot_ws/src/fishbot_navigation2/package.xml
11   /home/ros2/code/fishbot_ws/build/fishbot_navigation2/ament_cmake_core/package.cmake)
12   returned error code 1
13 Call Stack (most recent call first):
14   /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
15   /opt/ros/foxy/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
16   CMakeLists.txt:34 (ament_lint_auto_find_test_dependencies)
17 
18 
19 ---
20 Failed   <<< fishbot_navigation2 [0.29s, exited with code 1]
21                                 
22 Summary: 0 packages finished [0.42s]
23   1 package failed: fishbot_navigation2
24   1 package had stderr output: fishbot_navigation2
复制代码

 

解决方法:

pip3 install catkin_pkg

 

 

再次colcon build,成功了!因为此问题困住了好长时间,以前同样的方式没有任何问题,但突然新的工程都没法编译,而唯一的变化就是最近新安装了“conda”,它应该就是这个罪魁祸首了!

 

posted on   tdyizhen1314  阅读(1971)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示