0
$\begingroup$

Rosanswers logo

Hi, I am using Ubuntu 16.04. I was trying to build the docker image of autoware.ai using CUDA and colcon, but got errors about exception loading extension related to colcon. My environment:

  • Ubuntu 16.04
  • CUDA 10

I have tried different versions of Autoware.ai from 1.12.0 to the latest master branch, no one is working.

Below is part of the error log. The errors keep repeating for building each package:

13:13:48 dev@lambda-quad ~/autoware.ai $ AUTOWARE_COMPILE_WITH_CUDA=1 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.task.build.python': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_core/task/python/build.py", line 8, in 
    import setuptools  # noqa: F401
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.task.build.ros.ament_python': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 17, in 
    from colcon_core.task.python.build import PythonBuildTask
  File "/usr/lib/python3/dist-packages/colcon_core/task/python/build.py", line 8, in 
    import setuptools  # noqa: F401
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

[0.132s] ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.package_identification.python_setup_py': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 9, in 
    import setuptools
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

[0.135s] ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.package_identification.ros': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 16, in 
    from colcon_python_setup_py.package_identification.python_setup_py \
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 9, in 
    import setuptools
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

[0.279s] ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.package_augmentation.python_setup_py': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_augmentation/python_setup_py.py", line 9, in 
    from colcon_python_setup_py.package_identification.python_setup_py import \
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 9, in 
    import setuptools
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

[0.282s] ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.package_augmentation.ros': invalid syntax (dist.py, line 585)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
  File "/usr/lib/python3/dist-packages/colcon_core/entry_point.py", line 168, in load_entry_point
    return entry_point.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 16, in 
    from colcon_python_setup_py.package_identification.python_setup_py \
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 9, in 
    import setuptools
  File "/usr/local/lib/python3.5/dist-packages/setuptools/__init__.py", line 18, in 
    from setuptools.dist import Distribution
  File "/usr/local/lib/python3.5/dist-packages/setuptools/dist.py", line 585
    license_files: Optional[List[str]] = self.metadata.license_files
                 ^
SyntaxError: invalid syntax

There was no error before EOL of ROS kinetic. I am not sure whether this build error is related to the recent ROS Kinetic end-of-life. I have updated my ROS GPG key. Any one know why this error happened?


Originally posted by fangzhou on ROS Answers with karma: 13 on 2021-06-25

Post score: 1


Original comments

Comment by christophebedard on 2021-06-28:
It looks like you might have an older version of Python. It's complaining about type annotation, which is only supported from Python 3.5+. The traceback shows /usr/local/lib/python3.5/, so it would be weird if you didn't actually have Python 3.5, but I don't see any other explanation for that error. If you could provide all the commands you ran, the tutorial you followed, etc., we might be able to help.

Comment by christophebedard on 2021-06-28:
If you can, maybe try to modify any command you run/dockerfile you build to add the --include-eol-distros option for rosdep update. Kinetic is EOL, and it could cause some problems as you say, but this error seems unrelated.

Comment by fangzhou on 2021-07-01:
@christophebedard I have updated details of my question and the errors. I have python 3.5 installed. --include-eol-distros has been added before the build. I am not sure why this error happened. All I guess maybe related to the recent ROS Kinetic EOL.

Comment by christophebedard on 2021-07-02:
If you could provide all the commands you ran, the tutorial you followed, etc., we might be able to help, otherwise it's quite hard. How did you install colcon? Has colcon ever worked before on this machine/setup? Also, you say you're trying to build a dockerfile, but this looks like straight command-line.

Comment by fangzhou on 2021-07-02:
@christophebedard Thanks for the reply. The tutorial I followed is https://github.com/Autoware-AI/autoware.ai/wiki/Source-Build. I am using Ubuntu 16.04 and CUDA 10. The only difference is I use rosdep update --include-eol-distros for the ros update.

I was trying to build a docker image of a project based on Autoware, but got the build error. So I switched to build the Autoware.ai to see if it works, then I got the same build error.

I was able to build the Autoware.ai about 3 months ago. I use the same the same desktop and environment.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I was able to reproduce by following the tutorial (https://github.com/Autoware-AI/autoware.ai/wiki/Source-Build).

I don't know why exactly, but it seems that the last version of setuptools that is compatible with Python 3.5 (which is what we have on Ubuntu 16.04) is 51.3.3. However, by default with the pip3 install -U setuptools command (from the tutorial), we get version 57.0.0. The solution should therefore be to uninstall it and install 51.3.3:

pip3 uninstall setuptools && pip3 install setuptools==51.3.3

See this GitHub issue: https://github.com/pypa/setuptools/issues/2541#issuecomment-763275516. This fixes the SyntaxError with colcon build for me, but I haven't done any other validation.

Here are all the commands I ran, including the solution at the end: https://gist.github.com/christophebedard/349bff22f18285c6ebd9ecb1a2e79590


Originally posted by christophebedard with karma: 641 on 2021-07-02

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by fangzhou on 2021-07-06:
Thanks! I use "pip3 install setuptools==51.3.3" instead of "pip3 install -U setuptools" and it works. There are still some packages that cannot be built. But they belongs to different issues. Appreciate!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.