-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not import 'rosidl_typesupport_c' for package #303
Comments
I can't reproduce what you're seeing in Foxy. I followed the two tutorials you linked to, and I got this output with the custom
One place I noticed that needs updating in the first tutorial (Python pub/sub) is where it says to add the Where do you have your Otherwise I didn't see any discrepancies. I followed the tutorials exactly.
|
Thanks for getting back to me. I did have the tags inside $ ros2 pkg prefix rosidl_typesupport_c
/opt/ros/foxy |
To double-check, you have two separate packages for the Python nodes and the custom messages?
Sorry if this doesn't help, I feel like this is a configuration problem, as that message looks familiar, but I can't find any personal notes on it. Maybe someone else has a better idea. |
Not much to add from me. Something else I noticed though is that you have build, install, log inside the src directory. That might make things not work correctly. Make sure you delete those and run |
I deleted those and all build files and |
Since we can't reproduce it, I think you'll have to provide very specific step-by-step instructions on what you are doing, and with what code. |
Hi, I've made this temporary repository with the code I'm using and instructions to reproduce. Let me know if you get the same error, or what I missed here. Thanks! |
So, using your repo, everything unchanged and just running starting from
To further check that I have the latest binary environment to match the environment reported, I retested using our official foxy Docker image:
and I got the same results as above. I would recommend pulling the Docker image and comparing your environment with it. The results above suggest that the problem isn't in the code, it's in the configuration. |
Good news! I tried the image you sent like so: sudo docker pull ros:foxy-ros-base
sudo docker run -v ~/rosidl_ws:/home/joaquin/rosidl_ws --rm -i -t ros:foxy-ros-base bash Then tried # rm -rf build/ install/ log/
# colcon build
Starting >>> tutorial_interfaces
[0.258s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/joaquin/rosidl_ws/install/py_srvcli' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.258s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/joaquin/rosidl_ws/install/py_pubsub' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.258s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/joaquin/rosidl_ws/install/tutorial_interfaces' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.258s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/joaquin/rosidl_ws/install/tutorial_interfaces' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Finished <<< tutorial_interfaces [4.61s]
Starting >>> py_pubsub
Starting >>> py_srvcli
Finished <<< py_pubsub [0.66s]
Finished <<< py_srvcli [0.67s]
Summary: 3 packages finished [5.44s]
# . install/setup.bash
# ros2 run py_pubsub talkercustom
[INFO] [1615488166.694147981] [minimal_publisher]: Publishing: "0" How would I go about comparing my environment with this image? I am fairly new to using docker. |
Great! Glad you were able to get something other than an error. I don't have a real plan as to how exactly to compare... If it were me, I would just poke around without cursing until something good happens. Probably I would compare the environment variables Do you have multiple ROS versions installed? That shouldn't be a problem, as long as you source things in the right order (ROS 1 first, then ROS 2). If you do, I would suggest not sourcing ROS 1 at all, and just do a clean ROS 2 sourcing. |
Hmm, Here are the env differences which might attribute to the error: - (no container)
+ (container)
- LANG=en_US.UTF-8
+ LANG=C.UTF-8
- AMENT_PREFIX_PATH=/opt/ros/foxy
+ AMENT_PREFIX_PATH=/home/joaquin/rosidl_ws/install/py_srvcli:/home/joaquin/rosidl_ws/install/py_pubsub:/home/joaquin/rosidl_ws/install/tutorial_interfaces:/opt/ros/foxy
+ CMAKE_PREFIX_PATH=/home/joaquin/rosidl_ws/install/tutorial_interfaces
+ COLCON_PREFIX_PATH=/home/joaquin/rosidl_ws/install
- PYTHONPATH=/opt/ros/foxy/lib/python3.8/site-packages
+ PYTHONPATH=/home/joaquin/rosidl_ws/install/tutorial_interfaces/lib/python3.8/site-packages:/home/joaquin/rosidl_ws/install/py_srvcli/lib/python3.8/site-packages:/home/joaquin/rosidl_ws/install/py_pubsub/lib/python3.8/site-packages:/home/joaquin/rosidl_ws/install/tutorial_interfaces/lib/python3.7/site-packages:/opt/ros/foxy/lib/python3.8/site-packages
- LD_LIBRARY_PATH=/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
+ LD_LIBRARY_PATH=/home/joaquin/rosidl_ws/install/tutorial_interfaces/lib:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
- PATH=/opt/ros/foxy/bin:/home/joaquin/.bin:/home/joaquin/.pyenv/plugins/pyenv-virtualenv/shims:/home/joaquin/.pyenv/shims:/home/joaquin/.pyenv/bin:/home/joaquin/.bin:/home/joaquin/.pyenv/plugins/pyenv-virtualenv/shims:/home/joaquin/.pyenv/shims:/home/joaquin/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
+ PATH=/opt/ros/foxy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin From what I can tell by Thanks for your help thus far. |
what should the $ env
|
I had the same issue: |
Hi all, I had the same issue. After inspecting the build log I noticed these lines:
I modified CMakeLists.txt to below and it resolved it:
Hope this helps. |
I had the same issue. I follow this answer add DEPENDENCIES in rosidl_generate_interfaces to solve this problem. |
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. |
Since I don't think there is actually a bug here, I'm going to go ahead and close this one out. If you think there is a bug, please feel free to open a new issue with the exact reproducing steps. Otherwise, please ask questions on https://answers.ros.org. |
I 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 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. |
Hey everyone, Conclusion: Your python interpreter must match what was used to build the original binaries. |
Hi, |
Hello, |
For anyone still facing this issue (and since it's the first thing that pops up from Google), see #303 (comment). I also faced the error when trying to use Python 3.11 on ROS2 Humble, which uses pre-built Python 3.10 dist-packages. Matching my Python version to the ROS dist-packages worked for me too. You can check exactly which version the ROS dist-packages use with ~ » pip show rosidl-generator-c
Name: rosidl-generator-c
Version: 3.1.5
Summary: UNKNOWN
Home-page: UNKNOWN
Author:
Author-email:
License: UNKNOWN
Location: /opt/ros/humble/local/lib/python3.10/dist-packages # <-- Note python3.10 here
Requires:
Required-by: I was using a local ROS install, so I...
... and that fixed the missing import. I'm not sure how/why ROS2 injects its dist-packages into the Python environment, but |
I had this issue also, but in my case it was due to having a Conda environment enabled. Disabling the conda environment with |
谢谢你,super man! |
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 I also used 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. |
I also encoutered the issue and have solved it thanks to the kamronkhakimov' answer. To run Then to make sure that your python version conicides with the version you just found out, that means python-3.10 for me. |
Hi, I'm running into the same issue but my os is Windows 10. I looked into my ROS2 folder and saw that it was using Python3.8, which is also the version of Python that I'm using. I followed the same tutorial and I essentially get the same error. I quadruple checked all my code and it's identical to the one from the tutorial, but I still can't get rid of the error. Any help would be greatly appreciated. |
So I ran into this issue but resolved it through another method. For my system, I installed conda first before ros2, and was using the python interpreter associated with conda (python3.12), but not in a virtual environment. I realized that when installing ros2 by following the tutorial here, it also installed a python interpreter on my system at /usr/bin/python3 which is python3.8, and this has been the python interpreter that ros2 used throughout. However, it seems like the problem for me was that cmake (which is required for custom messages) was using the conda python3.12 while the rest of ros2 was using python3.8 which is what's causing the error. I resolved my problem by following this thread, which forces cmake to use the same interpreter as ros2. |
I had similar issues with ROS humble. It turned out that I had very old python3.6 packages and my system was compiling the rosidl_typesupport modules for python 3.6, and therefore were not loaded by my python interpreter (3.10). NB: my system was recently upgraded from Ubuntu 20.04 (one thing ROS maintainers would need to check is how the compiler for the modules is chosen...) |
Faced the same issue while implementing ROS custom message tutorial. Found out that ros install uses a different version. Fixing the CMake to use the specific Python installation as mentioned above finally solved the issue for me after a long session of debugging. |
Bug report
Required Info:
I have a set of packages built using
ament_python
in a workspace and have been trying to create a separate package, built usingament-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 usingros2 run py_pubsub talker
etc.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
listener
service
client
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
?The text was updated successfully, but these errors were encountered: