[ros-users] Python import error

Ken Conley kwc at willowgarage.com
Tue Jun 29 22:10:54 UTC 2010


Are you sure that the "joy" package is built?

I tried a simple test and this worked for me:

$ roscreate-pkg bar joy
... <snip>
kwc at bqv:/home/kwc/workspace$ cd bar
kwc at bqv:/home/kwc/workspace/bar$ echo "import roslib;
roslib.load_manifest('bar'); from joy.msg import Joy; print Joy" >
test.py
kwc at bqv:/home/kwc/workspace/bar$ python test.py
<class 'joy.msg._Joy.Joy'>


On Tue, Jun 29, 2010 at 3:04 PM, Mike Purvis
<mpurvis at clearpathrobotics.com> wrote:
> Hi all,
> I'm sorry if this a dumb question, but I'm having trouble importing the Joy
> message into my python script. My manifest:
> <package>
>   <description brief="clearpath_horizon">
>      clearpath_horizon
>   </description>
>   <author>Mike Purvis</author>
>   <license>BSD</license>
>   <review status="unreviewed" notes=""/>
>   ...
>   <depend package="joy"/>
>   ...
> </package>
> And then I run rosmake without a problem (and I can roscd to joy, and run
> joy_node without a problem, verifying its operation with rostopic echo).
> In my own node, I have:
> #!/usr/bin/python
> # ROS stuff
> import roslib; roslib.load_manifest('clearpath_horizon')
> import rospy
> from geometry_msgs.msg import Twist
> from joy.msg import Joy
> rospy.init_node('horizon_joy', anonymous=True)
> But on startup, it dies with:
>   File "/home/mpurvis/Clearpath/ros-clearpath/clearpath_horizon/src/joy.py",
> line 9, in <module>
>     from joy.msg import Joy
> ImportError: No module named msg
> Can anyone figure out what's going on here? I use messages from
> geometry_msgs and nav_msgs, and even gps_common. So I'm not sure what could
> be the issue here. Failing some silly error in the above, is there something
> special in the way the joy package is set up that I need to accommodate?
> Would it be better to just copy the message file over and remove the
> dependency?
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>



More information about the ros-users mailing list