Win10 x64、ROS 2 - 谦虚、VS 2019
我正在学习 ROS 初学者教程,但我在使用
colcon
构建软件包时遇到了问题,并了解了 使用 colcon 构建软件包 教程。
我从 VS 2019 命令行以管理员身份运行,我通过运行
ros2
文件来获取 local_setup.bat
。我安装了 colcon
扩展,下载了示例并按照教程中所述设置了目录结构。
然后我尝试使用
colcon
构建
colcon build --symlink-install --merge-install
安装几个软件包后会抱怨并中止构建,
--- stderr: examples_rclcpp_minimal_publisher
Traceback (most recent call last):
File "C:\ROS_Humble\ros2\share\ament_cmake_core\cmake\core\package_xml_2_cmake.py", line 22, in <module>
from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:95 (message):
execute_process(C:/ProgramData/Anaconda3/python.exe
C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
D:/ROS_scratch/dev/ros2_ws/src/examples/rclcpp/topics/minimal_publisher/package.xml
D:/ROS_scratch/build/examples_rclcpp_minimal_publisher/ament_cmake_core/package.cmake)
returned error code 1
Call Stack (most recent call first):
C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
C:/ROS_Humble/ros2/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
CMakeLists.txt:47 (ament_lint_auto_find_test_dependencies)
有人知道这是什么意思吗?我看过一些关于人们没有在正确的环境中采购
ros2
的帖子,但这不是这里的问题。
我首先尝试获取
catkin_pkg
模块并确保它已安装,基于:
ModuleNotFoundError: No module named 'catkin_pkg'
显然这应该可以解决问题:
pip install -U catkin_pkg
如果这没有帮助,那么我将更新我的答案,并提供有关如何调试此问题的提示,以便为我们获取更多信息。
如果您使用带有 anaconda 的本地环境,您应该尝试安装以下依赖项:
conda install -c conda-forge catkin_pkg empy lark
作为一个潜在的答案,对我来说,这个问题是由于通过 Windows 商店安装了第二个 python,该安装在正常程序和应用程序列表中不可见。使用 Windows 中的“较新”“添加或删除程序”选项后,我能够找到其他 python 安装,将其删除,并能够构建。