To execute modules as scripts in Catkin
Is there a way to run installed python modules as scripts in Catkin?
For instance, if you look at moveit_joy.py
source from moveit_ros_visualization
package, there are python files that contain classes (e.g. this) as well as main (if __name__ == "__main__":
), which tells me it's intended as both module and script.
$ dpkg -p ros-indigo-moveit-ros-visualization | grep Ver
Version: 0.6.5-0trusty-20160114-1001-+0000
$ rospack find moveit_ros_visualization
/opt/ros/indigo/share/moveit_ros_visualization
$ rosrun moveit_ros_visualization moveit_joy.py
[rosrun] Couldn't find executable named moveit_joy.py below /opt/ros/indigo/share/moveit_ros_visualization
# This module is callable as an argument for python interpreters. E.g.:
$ ipython /opt/ros/indigo/lib/python2.7/dist-packages/moveit_ros_visualization/moveit_joy.py
Unable to register with master node [http://localhost:11311]: master may not be running yet. Will keep trying.
(For the particular package above, because the module installed via distutils
/setup.py
is not callable, it's worked around by defining install rule in CMakeLists.txt, which works fine but now we have duplicate python files in the installed space.)
Update 6/23/2016 To execute modules as scripts, should I install python file as script
, or module
in Catkin?
UPDATE 2022/09/07 Years later I came to my own post again. While this thread doesn't provide much reasoning for "Why is it bad?", sounds like encouraging re-use-ability by separating module and executable can be a propelling reason. See #q222258