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

ImportError: cannot import name (trying to import .msg file from a folder in the same workspace as a python file that imports it)

asked 2021-10-27 18:57:20 -0500

MambaMentality24 gravatar image

updated 2021-10-28 05:47:08 -0500

Mike Scheutzow gravatar image

I am currently running ROS Melodic on a WSL/Ubuntu 18.04. I am trying to import a couple .msg files for a python project. Whenever I try to run my code, I always get the same error:

Traceback (most recent call last):
  File "/root/catkin_ws/src/beginner_tutorials/src/object_detector.py", line 6, in <module>
    from beginner_tutorials.msg import DetectedObjectInfo, TrackedObjectInfo
ImportError: cannot import name 'DetectedObjectInfo'

Because this website is not letting me attach photos, all I can do is show the line of where my error occurs:

from beginner_tutorials.msg import DetectedObjectInfo, TrackedObjectInfo

Inside my beginner_tutorials folder, I have a folder called "msg", with .msg files "DetectedObjectInfo.msg" and "TrackedObjectInfo.msg". There is also a folder called "src" inside the beginner_tutorials folder that contains the python file that I am using which contains the import statement with an error.

I'm pretty sure I added everything in my CMakeLists.txt file and package.xml file accordingly. Could anyone help me with this issue regarding the ImportErrors?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-28 00:09:56 -0500

MambaMentality24 gravatar image

Fixed my issue. It was because there were errors when I ran catkin_make. After fixing the problems that caused the errors when running cattkin_make, the line shown above was no longer and issue and actually worked.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-10-27 18:57:20 -0500

Seen: 766 times

Last updated: Oct 28 '21