examples: Could not import 'rosidl_typesupport_c' for package
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- Binaries
- Version or commit hash:
- foxy
- Client library (if applicable):
- rclpy
I have a set of packages built using ament_python in a workspace and have been trying to create a separate package, built using ament-cmake to contain custom message and service types. I was getting an error and posted it here, but have not found an answer. Then, I attempted to use the custom interface tutorial, which has steps for editing past rclpy examples to use custom interfaces. I ran into the same problem with the same output.
Steps to reproduce issue
Follow the rclpy publisher / subscriber or service / client tutorials and then the custom interfaces tutorial, editing those previous tutorial scripts to test the new interfaces.
colcon build should run without error. Then try running your new, edited script using ros2 run py_pubsub talkeretc.
Expected behavior
Should see the output at the end of the custom interfaces tutorial
Actual behavior
Here are some outputs from using ros2 run for different edited scripts.
talker
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tutorial_interfaces.tutorial_interfaces_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/py_pubsub/talkercustom", line 11, in <module>
load_entry_point('py-pubsub==0.0.0', 'console_scripts', 'talkercustom')()
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/python3.8/site-packages/py_pubsub/publisher_member_function_custom.py", line 27, in main
minimal_publisher = MinimalPublisher()
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/python3.8/site-packages/py_pubsub/publisher_member_function_custom.py", line 11, in __init__
self.publisher_ = self.create_publisher(Num, 'topic', 10) # CHANGE
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1140, in create_publisher
check_for_type_support(msg_type)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_type.__class__.__import_type_support__()
File "/home/joaquin/mlabs/dev_ws/install/tutorial_interfaces/lib/python3.7/site-packages/tutorial_interfaces/msg/_num.py", line 27, in __import_type_support__
module = import_type_support('tutorial_interfaces')
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'tutorial_interfaces'
listener
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tutorial_interfaces.tutorial_interfaces_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/py_pubsub/listenercustom", line 11, in <module>
load_entry_point('py-pubsub==0.0.0', 'console_scripts', 'listenercustom')()
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/python3.8/site-packages/py_pubsub/subscriber_member_function_custom.py", line 25, in main
minimal_subscriber = MinimalSubscriber()
File "/home/joaquin/mlabs/dev_ws/install/py_pubsub/lib/python3.8/site-packages/py_pubsub/subscriber_member_function_custom.py", line 11, in __init__
self.subscription = self.create_subscription(
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1201, in create_subscription
check_for_type_support(msg_type)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_type.__class__.__import_type_support__()
File "/home/joaquin/mlabs/dev_ws/install/tutorial_interfaces/lib/python3.7/site-packages/tutorial_interfaces/msg/_num.py", line 27, in __import_type_support__
module = import_type_support('tutorial_interfaces')
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'tutorial_interfaces'
service
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tutorial_interfaces.tutorial_interfaces_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/py_srvcli/service custom", line 11, in <module>
load_entry_point('py-srvcli==0.0.0', 'console_scripts', 'service custom')()
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/python3.8/site-packages/py_srvcli/service_member_function_custom.py", line 22, in main
minimal_service = MinimalService()
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/python3.8/site-packages/py_srvcli/service_member_function_custom.py", line 11, in __init__
self.srv = self.create_service(AddThreeInts, 'add_three_ints', self.add_three_ints_callback) # CHANGE
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1295, in create_service
check_for_type_support(srv_type)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_type.__class__.__import_type_support__()
File "/home/joaquin/mlabs/dev_ws/install/tutorial_interfaces/lib/python3.7/site-packages/tutorial_interfaces/srv/_add_three_ints.py", line 300, in __import_type_support__
module = import_type_support('tutorial_interfaces')
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'tutorial_interfaces'
client
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tutorial_interfaces.tutorial_interfaces_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/py_srvcli/clientcustom", line 11, in <module>
load_entry_point('py-srvcli==0.0.0', 'console_scripts', 'clientcustom')()
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/python3.8/site-packages/py_srvcli/client_member_function_custom.py", line 26, in main
minimal_client = MinimalClientAsync()
File "/home/joaquin/mlabs/dev_ws/install/py_srvcli/lib/python3.8/site-packages/py_srvcli/client_member_function_custom.py", line 11, in __init__
self.cli = self.create_client(AddThreeInts, 'add_three_ints') # CHANGE
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1248, in create_client
check_for_type_support(srv_type)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_type.__class__.__import_type_support__()
File "/home/joaquin/mlabs/dev_ws/install/tutorial_interfaces/lib/python3.7/site-packages/tutorial_interfaces/srv/_add_three_ints.py", line 300, in __import_type_support__
module = import_type_support('tutorial_interfaces')
File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'tutorial_interfaces'
As you can see, there is a pattern.
Additional information
I’m not the first person to have this problem, and I haven’t been able to find a solution or a workaround thus far. Should I stick to using pre-built messages? Build all my packages with ament_cmake?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 28 (2 by maintainers)
I had the same issue: My solution: One of may message dependencies(e.g. nav_msgs) was not included in my CMakeList.txt. Once it was added, the problem got resolved. If you have custom messages in your package, that could be the reason.
I had this issue also, but in my case it was due to having a Conda environment enabled. Disabling the conda environment with
conda deactivatebefore cleaning the workspace withrm -rf build installand building the workspace again withcolcon buildfixed the issue for me. For people more fluent with Python virtual environments there may be a way to get these working together, but I have no advice to give on thatI know this issue was just closed, but it’s happening to me too.
I have a hunch it has to do with mixing python versions. As it mentions here: 🌐 Using Python Packages with ROS 2
I have noticed I can use the
std_msgsjust fine, but my custom interfaces give theCould not import 'rosidl_typesupport_c' for packageerror. If I look at what Python sees insys.path, I see that my interfaces use Python 3.8 while the std_msgs (and the rest of my ROS binary) were compiled with 3.7.I haven’t been able to roll my build back to 3.7 or get an updated binary using 3.8 yet, but that’s my current theory.
I had the same issue. I follow this answer add DEPENDENCIES in rosidl_generate_interfaces to solve this problem.
Hey everyone, I had the same issue with ‘rosidl_typesupport_c’ and I’ve solved it after reading the comment of @mozilla2012. In Ubuntu 20.04 LTS, I use virtualenv to run python 3.7 and 3.8 (which is used by the system interpreter). After settings up a new python3.8 venv + running
rosdep installundcolcon buildwith this particular python version, I was able to launch ROS2 without the mentioned problem.Conclusion: Your python interpreter must match what was used to build the original binaries.
Hello, I met the same problem as you. I found that this is because I currently use the anaconda environment instead of the system environment of python3.6. When I use ‘’$ conda deactivate‘’ command, the error disappeared.I hope it can help you.
I solved the issue by using a different version of python, the one that is also used in the ros2 code. The exact version is in the build folder of your ros2 workspace. Just run
grep python . -rand you’ll find the version somewhere in there.I also used
virtualenvinstead of changing my python version globally.You also might need to install some of the modules along the way, like empy 3.3.4, lark, catkin_pkg, since some older python versions might not include those packages, that newer versions have builtin.
Hi, I had the same issue, building in docker and running in another environment. The issue was a version mismatch of ros-galactic-rosidl-typessuport-c between the building environment and the running environment. Hope this helps as I’ve lost some hours on it 🙄