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

Failed to build with colcon: "cannot import name 'has_ros_schema_reference'"

asked 2019-12-10 01:29:33 -0600

yossi_ov gravatar image

Having a clean workspace with single empty folder src , I source ROS2 by calling source /opt/ros/dashing/setup.bash and running colcon build I get an exception in colcon core package (or catkin_pkg package ?) as displayed below:

[0.164s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'ros' in '/home/yossi/temp_ws': cannot import name 'has_ros_schema_reference'

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/package_identification/__init__.py", line 143, in _identify
    retval = extension.identify(_reused_descriptor_instance)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 59, in identify
    pkg, build_type = get_package_with_build_type(str(desc.path))
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 163, in get_package_with_build_type
    pkg = _get_package(path)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 171, in _get_package
    from catkin_pkg.package import has_ros_schema_reference
ImportError: cannot import name 'has_ros_schema_reference'

[0.166s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'ros' in '/home/yossi/temp_ws/src': cannot import name 'has_ros_schema_reference'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/package_identification/__init__.py", line 143, in _identify
    retval = extension.identify(_reused_descriptor_instance)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 59, in identify
    pkg, build_type = get_package_with_build_type(str(desc.path))
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 163, in get_package_with_build_type
    pkg = _get_package(path)
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 171, in _get_package
    from catkin_pkg.package import has_ros_schema_reference
ImportError: cannot import name 'has_ros_schema_reference'


Summary: 0 packages finished [0.08s]

I've tried to purge and reinstall ALL packages relevant to ROS1, ROS2, colcon, catkin but that did not help.

In fact, having ROS2 uninstalled and trying to run colcon build in the same workspace yields the same error.

The problem started to occur at some point couple days ago, before that I used this system for several months for both ROS1 and ROS2 development.

Any ideas what could have happen to it and is there a way to solve it before reinstalling the whole system?

Additional information:

└─▶ $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

Relevant environment variables:

└─▶ $ printenv | grep -i -e ROS -e CATKIN -e CMAKE -e RMW
LD_LIBRARY_PATH=/opt/ros/dashing/opt/yaml_cpp_vendor/lib:/opt/ros/dashing/opt/rviz_ogre_vendor/lib:/opt/ros/dashing/lib:/opt/rti.com/rti_connext_dds-5.3.1/lib/x64Linux3gcc5.4.0
AMENT_PREFIX_PATH=/opt/ros/dashing
ROS_VERSION=2
ROS_PYTHON_VERSION=3
PYTHONPATH=/opt/ros/dashing/lib/python3.6/site-packages
PATH=/opt/ros/dashing/bin:/opt/rti.com/rti_connext_dds-5.3.1/lib/x64Linux3gcc5.4.0:/opt/rti.com/rti_connext_dds-5.3.1/bin:/home/yossi/ardupilot/Tools/autotest:/opt/gcc-arm-none-eabi-4_9-2015q3/bin:/home/yossi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/yossi/.dotnet/tools
ROS_DISTRO=dashing
edit retag flag offensive close merge delete

Comments

Could you share your versions of colcon-ros and catkin-pkg-modules?

You need catkin_pkg(_modules) >= 0.4.14 for the has_ros_schema_reference function to exist

marguedas gravatar image marguedas  ( 2019-12-10 02:42:39 -0600 )edit

Please post the output of dpkg -l | grep catkin-pkg as well as python3 -c "import catkin_pkg; print(catkin_pkg.__version__)".

Dirk Thomas gravatar image Dirk Thomas  ( 2019-12-10 10:51:48 -0600 )edit

Unfortunately I had to reformat the computer and can't check anything anymore

@marguedas It was latest updated by apt

@clyde That's the one option I haven't tried. Probably that could solve it...

yossi_ov gravatar image yossi_ov  ( 2019-12-11 07:00:54 -0600 )edit

1 Answer

Sort by » oldest newest most voted
5

answered 2019-12-10 20:38:08 -0600

clyde gravatar image

I ran into this a few days ago. The problem turned out to be an older version of catkin_pkg/package.py installed by pip3 install hiding the just released version installed by apt install. I cleaned up my Python environment and the problem went away.

edit flag offensive delete link more

Comments

4

Thanks! This fixed the issue for me too. For anyone trying to decide if this the same issue, run python3 -c "import catkin_pkg; import inspect; print(inspect.getfile(catkin_pkg))". On Ubuntu bionic that should print /usr/lib/python3/dist-packages/catkin_pkg/__init__.py. If you get any other path it means catkin_pkg is being imported from somewhere else, probably a pip install. Remove it with pip3 uninstall catkin_pkg.

sloretz gravatar image sloretz  ( 2019-12-13 09:53:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-12-10 01:29:33 -0600

Seen: 2,227 times

Last updated: Dec 10 '19