ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
10

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

asked 2022-02-19 07:41:35 -0600

Hairy ass gravatar image

updated 2023-04-07 01:41:40 -0600

130s gravatar image

I am trying to create a package called helloworld that print out a message

cd ~/ro2_ws/src
ros2 pkg create --build-type ament_python helloworld

Inside helloworld/helloworld/nodefile.py

def main():
    print('Hello world')

Inside helloworld/setup.py

from setuptools import setup

package_name = 'helloworld'

setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    data_files=[
        ('share/ament_index/resource_index/packages',
                ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='TODO',
    maintainer_email='TODO',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'nodefile = helloworld.nodefile:main'
        ],
    },
)

I try to compile it

colcon build --packages-select helloworld

I get

--- stderr: helloworld                   
/usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
---
Finished <<< helloworld [0.76s]

Summary: 1 package finished [0.93s]
  1 package had stderr output: helloworld

So what is going on

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
27

answered 2022-05-04 01:19:00 -0600

noshluk2 gravatar image

Solved it. Problem is because of a package utilized by ros2 python packages -> setuptools

Solution

  • python version 3.8
  • setup tools version 58.2.0 ( last version to work with ros2 python packages without any warnings)

1 - find out your setup tools version

  • In terminal start python

image description

if it is above 58.2.0 then down grade it

  • pip install setuptools==58.2.0 ( all above versions do not work )

now colcon build it .

2 - Make sure you have underscores in setup.cfg file and not the '-' .

edit flag offensive delete link more

Comments

2

Can I do the same if I'm using ROS2 Humble which uses Python 3.10.6? I just need to downgrade the setuptools version to 58.2.0?

andrestoga gravatar image andrestoga  ( 2023-01-02 13:29:08 -0600 )edit

Setuptools version 58.2.0 is the last version that works with ROS 2 python packages without any warnings because it is the last version that supports the old installation method, "python setup.py install." This method has been deprecated and replaced by newer, standards-based tools, such as pip and ament.

ma ar gravatar image ma ar  ( 2023-01-29 16:11:26 -0600 )edit

It worked for me on Ubuntu 22.04 with ROS2 Humble.

Markus Bader gravatar image Markus Bader  ( 2023-02-16 06:12:03 -0600 )edit

thanks for the solutions

Zac Zhuo Zhang gravatar image Zac Zhuo Zhang  ( 2023-05-09 08:02:55 -0600 )edit

I downgraded setuptools to 58.2.0 but I still get the same error when I run colcon build What do I need to do to fix it?

Mehdi_gh gravatar image Mehdi_gh  ( 2023-05-10 09:35:49 -0600 )edit

Show the error @mehdi

noshluk2 gravatar image noshluk2  ( 2023-05-10 22:59:10 -0600 )edit

Worked for me on Ubuntu 22.04 with ROS2 Humble and Python Version 3.10.6 Just downgrade the setuptools.

Nils Heidemann gravatar image Nils Heidemann  ( 2023-05-30 03:38:54 -0600 )edit
5

answered 2022-03-31 01:37:16 -0600

ijnek gravatar image

updated 2022-03-31 02:15:11 -0600

This issue seems to be coming from ROS2 directly calling setup.py when building your package (which became deprecated in Python3.10).

The transition to Python3.10 for ROS2 Rolling happened only recently, and this is probably one of the issues that arose from it (but has not been fixed yet). Even if this does get fixed, it is unlikely the changes will be ported back to Foxy because the target platform for Foxy is Ubuntu20.04 which uses Python3.8 by default.

/usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

Your error message indicates that you're using Python3.10 to compile a ROS2 Foxy package. For this to happen, you must have manually installed Python3.10, installed a very recent version of Ubuntu (eg. 22.04), OR you're using a non-Ubuntu OS.

The recommended easy fix would be to revert to Python3.8 if you intend to use ROS2 Foxy.

I have raised an issue about this in ament_cmake

edit flag offensive delete link more

Comments

I'm not sure if this is strictly a Rolling issue. I see the same error on Humble.

waspinator gravatar image waspinator  ( 2022-09-09 15:24:06 -0600 )edit

You're right, at the time the question was posted, ROS 2 Humble wasn't yet released :)

ijnek gravatar image ijnek  ( 2022-09-09 19:10:14 -0600 )edit
2

answered 2022-09-30 16:50:39 -0600

PointCloud gravatar image

updated 2022-09-30 16:52:07 -0600

Good day, I just came across the same issue, following the ROS2 <humble> tutorial on python based services. Reason I came across this post, I am facing the same issue and can confirm it is still a problem in ROS <humble>. Here the info about my setup:

Ubuntu 22.04.1 LTS

> Python 3.10.6 (main, Aug 10 2022,
> 11:40:04) [GCC 11.3.0] on linux
> >>> import setuptools
> >>> print(setuptools.__version__)
> 59.6.0
> >>>

I will just continue for now and ignore this. Hopefully that's the best strategy and it will get addressed sometime soon

edit flag offensive delete link more

Comments

Yup, I can confirm. Fresh Ubuntu 22.04 in Docker container hast this version of setuptools with the deprecation warning.

maxpol gravatar image maxpol  ( 2022-10-27 08:18:29 -0600 )edit
-1

answered 2022-03-16 08:56:44 -0600

hi, you can simply remove the line install_requires=['setuptools'], from the file setup.py and also add --allow-overriding to rebuild your hello world.

edit flag offensive delete link more

Comments

This did not work for me. :/

nagda9 gravatar image nagda9  ( 2022-03-28 13:17:38 -0600 )edit

Question Tools

6 followers

Stats

Asked: 2022-02-19 07:41:35 -0600

Seen: 59,648 times

Last updated: Apr 07 '23