Hi There,
I am following the python publisher/subscriber tutorial located here. I followed the first couple of steps to download and build the code. Then, as instructed, I started a roscore and in a new terminal I ran "rosrun node_example pyttalker.py". That's when the following error came up:
Traceback (most recent call last):
File "/home/icolwell/node_example/src/pytalker.py", line 14, in <module>
from node_example.msg import NodeExampleData
ImportError: No module named msg
It appears that python can't find the python headers for the custom ROS message. I did a bit of investigating and these are the results:
1 The output of "rosmsg package node_example" is:
node_example/NodeExampleData
So it appears that ROS is aware that custom messages exist.
2 I also tried to ensure my $PYTHONPATH includes node_example by running "source ~/node_example/devel/setup.bash". Then the output of "echo $PYTHONPATH" was:
/home/icolwell/node_example/devel/lib/python2.7/dist-packages:/home/icolwell/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages
3 The contents of "~/node_example/devel/lib/python2.7/dist-packages/node_example/msg" is totally empty. Is this correct? I would assume that there should be something there that was built according to CMakeLists.txt but I am not familiar with python modules.
I also looked around online and other people have had similar problems. However, they seemed to be caused by a screwed up package.xml or CMakeLists.txt file. This doesn't seem to be the case here since it is unmodified tutorial code, and it appears that all the correct message generation related dependencies are there.
Does anyone have any idea what is happening here? Or at the very least is someone able to reproduce the same error? I am running Indigo on 14.04.
Any help will be greatly appreciated :D
Originally posted by IanCol on ROS Answers with karma: 253 on 2016-05-04
Post score: 1
Original comments
Comment by spmaniato on 2016-05-04:
The example package has been catkin-ized since the ROS wiki tutorial was written. Try building it with catkin_make
instead of the cmake .
and rosmake
stuff. Also, what's the output of rosmsg show NodeExampleData
?
Comment by jarvisschultz on 2016-05-05:
Your point 3 indicates that there is something wrong with your build process. If custom messages from the node_example
package are properly built, the Python message implementations should be in the directory you mentioned.
Comment by jarvisschultz on 2016-05-05:
I went ahead and converted your comment to an answer. If the question is no longer applicable, it is best if it shows up as answered. Feel free to edit the text, and please accept your own answer. Glad the problem disappeared!