Cannot import custom message using rospy (Groovy) [closed]
I have several custom messages created. I can safely import all of them except for one. Running rosmsg show
finds the message. I have done the catkin_make and rebuilt the project. The auto-generated header for the message file exists in devel/include. The message is included in add_message_files()
in CMakeLists.txt. Despite all of this, I have a script (i.e., my_pack/scripts/my_script.py) that tries:
from my_pack.msg import MyMessageType1, MyMessageType2
gives me
ImportError: cannot import name MyMessageType2
I can't see any differences between MyMessageType1
and MyMessageType2
. Does anyone have any ideas on what could cause an error like this?
EDIT: I have seen this question: http://answers.ros.org/question/52687/cannot-find-custom-message-groovy/ in which the problem might have been the message being inconsistently named. This is not the case for me, the message is the same name everywhere.
Please explain more carefully where you tried to import MyMessageType2. Check devel/lib/python2.7/dist-packages/my_pack/msg/__init__.py, and _MyMessageType2.py for anything odd. The only other thing I could imagine is that you use the installspace instead of develspace, but have not installed yet.
@KruseT I updated the question to include where I tried the import (catkin_workspace/src/my_pack/scripts/my_script.py). I have a setup.py that includes all the scripts in the scripts folder and
catkin_python_setup()
is called from CMakeLists.txt. I do not have an install space, only a devel space.@KruseT I can't see anything odd in the files you mentioned.
__init__.py
has bothfrom _MyMessageType1 import *
andfrom _MyMessageType2 import *
, and_MyMessageType1.py
and_MyMessageType2.py
look very similar (with the fields being slightly different, of course).Same problem here... any solution yet? Have you found the cause?
How this question is "not relevant" ... ???