ImportError: bad magic number in 'rosbag': b'\x03\xf3\r\n'

asked 2021-05-28 14:08:13 -0600

sandip1604 gravatar image

updated 2021-05-29 04:58:55 -0600

I am trying to run the python file called 'bag_parse.py' that imports rosbag package using the following command:

python bag_parse.py

My Python file is simple for testing:

import rosbag
bag = rosbag.Bag('scan_odom1.bag')
for topic, msg, t in bag.read_messages(topics=['/odom']):
    print(msg)
bag.close()

I get the following error:

ImportError: bad magic number in 'rosbag': b'\x03\xf3\r\n'

ROS distribution: Melodic

edit retag flag offensive close merge delete