You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行colcon build遇SetuptoolsDeprecationWarning问题求助

解决colcon build时setuptools弃用警告的方案

排查环境版本匹配问题

  • 先确认colcon实际调用的Python环境中setuptools版本:
    • 执行which python3找到colcon使用的Python路径
    • 用该路径检查版本:/path/to/python3 -m pip show setuptools
    • 如果显示的不是58.2.0,说明你降级的是其他环境的setuptools,需要对colcon使用的环境重新降级:/path/to/python3 -m pip install setuptools==58.2.0

强制colcon使用指定Python环境

  • 通过环境变量指定:
    export PYTHON_EXECUTABLE=/path/to/your/python3
    export PYTHONPATH=/path/to/your/env/lib/pythonX.Y/site-packages
    
  • 或者在build时直接指定:
    colcon build --cmake-args -DPYTHON_EXECUTABLE=/path/to/python3
    

针对自定义ROS包的修改

如果警告来自你维护的ROS包:

  • 在package.xml中添加依赖声明:
    <exec_depend>setuptools</exec_depend>
    
  • 在setup.py开头添加警告抑制代码:
    import warnings
    from setuptools import SetuptoolsDeprecationWarning
    warnings.filterwarnings("ignore", category=SetuptoolsDeprecationWarning)
    

更新colcon工具链

旧版colcon可能依赖弃用的setup.py安装方式,执行升级:

pip3 install --upgrade colcon-common-extensions

处理系统级setuptools(针对Ubuntu/Debian)

如果是系统包管理器安装的setuptools,需要降级系统版本:

  1. 查找对应版本的包:apt-cache policy python3-setuptools
  2. 安装指定版本:
    sudo apt install python3-setuptools=58.2.0-1ubuntu1
    
    (注:版本号需根据你的系统版本调整,确保和58.2.0对应)

内容的提问来源于stack exchange,提问作者Mehdi Ghorbani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 13:50:01