Ask Your Question
0

AttributeError when importing rospy

asked 2020-08-17 05:04:45 -0500

jack_johns gravatar image

Hello there.

When trying to run a python script that imports and uses rospy, I get the following error.

Traceback (most recent call last):
  File "./client_video.py", line 35, in <module>
    import rospy
  File "/usr/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/usr/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Empty import *
  File "/usr/lib/python2.7/dist-packages/std_msgs/msg/_Empty.py", line 9, in <module>
    class Empty(genpy.Message):
AttributeError: 'module' object has no attribute 'Message'

I used -y when apt-get installing python-rospy so the prerequisites should be installed too.

Any help would be much appreciated.

Using ROS Kinetic and Ubuntu 16.04.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-17 10:17:03 -0500

gvdhoorn gravatar image

updated 2020-08-17 10:23:12 -0500

I used -y when apt-get installing python-rospy so the prerequisites should be installed too.

The correct package name for rospy on ROS Kinetic would be ros-kinetic-rospy.

It would seem you've installed the UpstreamPackage version of rospy.

See "upstream packages" increasingly becoming a problem for a discussion about this on ROS Discourse.

Unless you did this on purpose, I would suggest you revert this and install the correct package instead.

edit flag offensive delete link more

Comments

Also:

I used -y when apt-get installing python-rospy so the prerequisites should be installed too.

Adding -y to the apt-get command line will only make apt-get assume yes on all questions. It doesn't necessarily do anything special with dependencies.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-17 10:21:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-17 05:04:45 -0500

Seen: 910 times

Last updated: Aug 17 '20