ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Can't import rospy

asked 2016-08-20 15:29:50 -0500

akb gravatar image


I have a ROS aplication in Python and Qt, and when I run it from the terminal all is ok, but I try to run with double click (the script with the permissions and Nautilus configuration appropriate) and the aplication can't import rospy.

I use ROS Indigo and Ubuntu 14.04.

Any idea? thanks!

edit retag flag offensive close merge delete


rospy is not on the default PYTHONPATH, and so without sourcing the appropriate /opt/ros/$distro/setup.* script won't be resolvable for Python. It's probable that by 'double clicking', the environment is not properly setup, leading to the problems you describe.

gvdhoorn gravatar image gvdhoorn  ( 2016-08-21 05:15:19 -0500 )edit

That happened, I could discovered it with you advice, thank you!

akb gravatar image akb  ( 2016-08-21 15:22:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-21 15:22:38 -0500

akb gravatar image

As gvdhoorn sais, the environment wasn't setup.

This link help me:

I have put the ros variable enviroment in a new file ~/.myenvironmentvariables and I load it from ~/.bashrc (for Terminal) and from the file /etc/X11/Xsession.d/40x11-common_xsessionrc from Files Browser. Just with the code source ~/.myenvironmentvariables. And finally rospy can be import with double click in nautilus.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-08-20 15:29:50 -0500

Seen: 5,358 times

Last updated: Aug 21 '16