0
$\begingroup$

Rosanswers logo

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

Originally posted by yossi_ov on ROS Answers with karma: 78 on 2019-12-10

Post score: 1


Original comments

Comment by marguedas on 2019-12-10:
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

Comment by Dirk Thomas on 2019-12-10:
Please post the output of dpkg -l | grep catkin-pkg as well as python3 -c "import catkin_pkg; print(catkin_pkg.__version__)".

Comment by yossi_ov on 2019-12-11:
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...

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by clyde with karma: 1247 on 2019-12-10

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by sloretz on 2019-12-13:
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.

$\endgroup$

Your Answer

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