ros2 / examples

Example packages for ROS 2
Apache License 2.0
681 stars 308 forks source link

I got "ImportError: cannot import name 'Union' from 'types'" when I colcon build the examples #367

Closed JimXu1989 closed 8 months ago

JimXu1989 commented 8 months ago

Bug report

Required Info:

Steps to reproduce issue

colcon build --symlink-install

Expected behavior

Actual behavior

Additional information

python 3.10

Feature request

Feature description

--- stderr: examples_rclpy_minimal_action_client Traceback (most recent call last): File "/usr/lib/python3/dist-packages/colcon_core/executor/init.py", line 91, in call rc = await self.task(*args, *kwargs) File "/usr/lib/python3/dist-packages/colcon_core/task/init.py", line 93, in call return await task_method(args, kwargs) File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 102, in build return await extension.build(additional_hooks=additional_hooks) File "/usr/lib/python3/dist-packages/colcon_core/task/python/build.py", line 85, in build available_commands = await self._get_available_commands( File "/usr/lib/python3/dist-packages/colcon_core/task/python/build.py", line 175, in _get_available_commands output = await check_output( File "/usr/lib/python3/dist-packages/colcon_core/subprocess.py", line 129, in check_output assert not rc, f'Expected {args} to pass: {stderr_data}' AssertionError: Expected ['/usr/bin/python3', 'setup.py', '--help-commands'] to pass: Traceback (most recent call last): File "/home/xss/ros2_ws/src/examples/rclpy/actions/minimal_action_client/setup.py", line 5, in setup( File "/usr/lib/python3/dist-packages/setuptools/init.py", line 153, in setup return distutils.core.setup(attrs) File "/usr/lib/python3.10/distutils/core.py", line 134, in setup ok = dist.parse_command_line() File "/usr/lib/python3.10/distutils/dist.py", line 480, in parse_command_line if self.handle_display_options(option_order): File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1126, in handle_display_options return _Distribution.handle_display_options(self, option_order) File "/usr/lib/python3.10/distutils/dist.py", line 683, in handle_display_options self.print_commands() File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 902, in print_commands cmdclass = ep.resolve() File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2471, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/home/xss/.local/lib/python3.10/site-packages/sphinx/setup_command.py", line 21, in from sphinx.application import Sphinx File "/home/xss/.local/lib/python3.10/site-packages/sphinx/application.py", line 31, in from sphinx.config import Config File "/home/xss/.local/lib/python3.10/site-packages/sphinx/config.py", line 21, in from sphinx.util import logging File "/home/xss/.local/lib/python3.10/site-packages/sphinx/util/init.py", line 41, in from sphinx.util.typing import PathMatcher File "/home/xss/.local/lib/python3.10/site-packages/sphinx/util/typing.py", line 37, in from types import Union as types_Union ImportError: cannot import name 'Union' from 'types' (/usr/lib/python3.10/types.py)


Failed <<< examples_rclpy_minimal_action_client [16.4s, exited with code 1]

Implementation considerations

clalancette commented 8 months ago

Please open questions like this on https://robotics.stackexchange.com/questions/tagged/ros, which is our central Question and Answer site. You'll get a better answer there, and it will be searchable for the future.

Make sure to include a lot of information on what platform you are using, which ROS distribution you are using, and the exact steps you took.