目录
提出问题——SetuptoolsDeprecationWarning
分析问题——构建时用setup.py的方法已被弃用
解决方法——降档使用setuptools
赠品:如何查询setuptools的版本
提出问题——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. https://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。文章来源:https://www.toymoban.com/news/detail-448808.html
#回退安装指令
pip install setuptools==58.2.0
至此,问题解决,继续往前。文章来源地址https://www.toymoban.com/news/detail-448808.html
赠品:如何查询setuptools的版本
#在python3环境中,执行以下代码
import setuptools
print(setuptools.__version__)
到了这里,关于玩转ROS2的填坑之路-SetuptoolsDeprecationWarning: setup.py install is deprecated的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!