我正在尝试从 Python 3 读取 rosbag 文件。
我安装了 ROS2(Eloquent Elusor),它应该支持 Python 3。
当我跑
import rosbag
bag = rosbag.Bag('test.bag')
从 Python 2.7 开始,它可以工作。
当我在 Python 3 中尝试相同的操作时,我得到:
ModuleNotFoundError: No module named 'rosbag'
我也尝试过类似的东西:和sudo apt install python-rosbag
,但它们没有帮助。sudo apt install python3-rospkg
pip3 install rospkg
我应该怎么做才能从 Python 3 打开一个 rosbag 文件?
[编辑]
这是调用后的输出pip3 install rospkg
:
Requirement already satisfied: rospkg in ./rosbag-env/lib/python3.6/site-packages
Requirement already satisfied: catkin-pkg in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: distro in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: PyYAML in ./rosbag-env/lib/python3.6/site-packages (from rospkg)
Requirement already satisfied: pyparsing in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: python-dateutil in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: docutils in ./rosbag-env/lib/python3.6/site-packages (from catkin-pkg->rospkg)
Requirement already satisfied: six>=1.5 in ./rosbag-env/lib/python3.6/site-packages (from python-dateutil->catkin-pkg->rospkg)