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

How do I include the Python "packaging" library on build farm?

asked 2019-12-24 00:23:54 -0600

max-krichenbauer gravatar image


I'm confused how to properly include a requirement for the Python packaging library into my package.

As far as I understand, that library is called python-packaging in ROS, so I added it to my package.xml. On my local system, it builds and runs without problems, but on the build farm, it fails with

05:55:04 Traceback (most recent call last):
05:55:04   File "/tmp/ws/install_isolated/ament_virtualenv/lib/python3.6/site-packages/ament_virtualenv/", line 30, in <module>
05:55:04     from packaging.requirements import Requirement, InvalidRequirement
05:55:04 ModuleNotFoundError: No module named 'packaging'


05:55:05 [1.060s]   File "/usr/local/lib/python3.6/dist-packages/pkg_resources/", line 786, in resolve
05:55:05 [1.061s]     raise DistributionNotFound(req, requirers)
05:55:05 [1.061s] pkg_resources.DistributionNotFound: The 'packaging' distribution was not found and is required by ament-virtualenv

I've tried all forms of dependencies (build_depend, buildtool_depend, exec_depend, ...), and tried adding either packaging or python-packaging to the install_requires section in / setup.cgf.

Can someone please let me know the proper way to include packaging (the Python library) so that it'll build on the build farm as well?

Here is the build farm log for reference:

and the source code repository:

Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-12-24 02:08:23 -0600

marguedas gravatar image

ROS 2 is targeting Python3 only. python-packaging refers to the Python 2 package. The rosdep key should be python3-packaging (the same applies to all python-* dependencies in you package.xml.

If the key doesn't exist in rosdep, you can contribute it following these instructions


edit flag offensive delete link more


Thank you for your answer @marguedas ! I changed it, but now I'm getting KeyError: 'python3-packaging' and RuntimeError: Could not resolve the rosdep key 'python3-packaging'. Any ideas why?

max-krichenbauer gravatar image max-krichenbauer  ( 2019-12-24 03:01:10 -0600 )edit

That sounds like the key does not exist as predicted above in the answer. With links how to resolve it.

tfoote gravatar image tfoote  ( 2019-12-24 03:03:12 -0600 )edit

I looked on and it seems there is no python3-packaging:

max-krichenbauer gravatar image max-krichenbauer  ( 2019-12-24 03:07:07 -0600 )edit

Thanks @tfoote Sorry, but I don't understand what you mean with "With links how to resolve it."?

max-krichenbauer gravatar image max-krichenbauer  ( 2019-12-24 03:09:52 -0600 )edit

@tfoote referred to these lines in the linked documentation:

For convenience in reviewing, please comment in the PR with links to the web listings of packages such as on,, and or if a pip package

gvdhoorn gravatar image gvdhoorn  ( 2019-12-24 03:28:38 -0600 )edit

As @tfoote mentioned, the rosdep key for python3-packaging doesn't exist yet. In my answer I provided links to the instructions to how to contribute new rosdep rules. You should follow them and contribute a new rule python3-packaging

marguedas gravatar image marguedas  ( 2019-12-24 03:51:44 -0600 )edit

Thank you, now I understood. I'll try to get the key added.

max-krichenbauer gravatar image max-krichenbauer  ( 2019-12-24 04:40:54 -0600 )edit

Question Tools

1 follower


Asked: 2019-12-24 00:23:54 -0600

Seen: 557 times

Last updated: Dec 24 '19