玩转ROS2的填坑之路-SetuptoolsDeprecationWarning: setup.py install is deprecated

目录


提出问题——SetuptoolsDeprecationWarning

自从使用Ubuntu22.04和ROS2后,接触到的项目都是用C++。最近为了调用pymodbus,开始尝试用python编写软件包。于是遇到了一系列的小问题,SetuptoolsDeprecationWarning是第一个。

SetuptoolsDeprecationWarning: setup.py install is deprecated. 
Use build and pip and other standards-based tools

分析问题——构建时用setup.py的方法已被弃用

首先,问题代码借用了官网提供的最小化框架,短小精悍,应该不可能在编译阶段就出问题。

# 可作为模板的最小化例子程序,值得借鉴
git clone -b humble --recursive https://github.com/ros2/examples.git  src

根据提示,在网上搜了搜,基本否定python安装包的版本问题了。据说无论是ROS2 foxy还是ROS2 humble都存在这个问题。

最后找到ROS论坛的这篇文章。

SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. icon-default.png?t=M85Bhttps://answers.ros.org/question/396439/setuptoolsdeprecationwarning-setuppy-install-is-deprecated-use-build-and-pip-and-other-standards-based-tools/

大意是,构建程序时使用setup.py的方法已被弃用。该问题目前尚未解决。

解决方法——降档使用setuptools

不过,别担心,有个折中的处理方式。

换一个setuptools版本,选择与ROS2一起工作不产生任何warning的版本。

能满足这个条件的setuptools版本中,最新的是58.2.0。

#回退安装指令
pip install setuptools==58.2.0

至此,问题解决,继续往前。

赠品:如何查询setuptools的版本

#在python3环境中,执行以下代码
import setuptools
print(setuptools.__version__)

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
乘风的头像乘风管理团队
上一篇 2023年3月5日 下午9:27
下一篇 2023年3月5日

相关推荐