Robotics StackExchange | Archived questions

can't use sudo rosbag

I can use rosbag by "rosbag record" and "sudo su" then "rosbag record" ,but I can't “sudo rosbag” I will get that:: ""Traceback (most recent call last): File "/opt/ros/melodic/bin/rosbag", line 34, in import rosbag ImportError: No module named rosbag"" How should I config env?

Asked by datnt2509 on 2019-08-20 21:39:32 UTC

Comments

have you sourced the ros env? source /opt/ros/<DISTRO>/setup.bash

Asked by PapaG on 2019-08-20 23:32:46 UTC

Answers

When you use sudo by default it removes your environment. You need to use -E to keep the environment.

https://stackoverflow.com/questions/8633461/how-to-keep-environment-variables-when-using-sudo

Asked by tfoote on 2019-08-21 17:58:58 UTC

Comments