ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

Python script works locally but not through SSH

Hello everyone!

I’m trying to link a Raspberry pi with pycroft with a Turtlebot. I have created a skill and I want that when I said “go to somewhere” the turtlebot goes to this place.

I have a python script and it works fine if firstly I connect via ssh and then I execute python go_to_specific_point_on_map.py

ssh tb2@192.168.0.158 python go_to_specific_point_on_map.py

But if I tried to do all in one command, I get:
ImportError: No module named ‘rospy’

$ ssh tb2@192.168.0.158 python go_to_specific_point_on_map.py

I think it is a problem due to .bashrc is not loaded and neither do the alias. I don’t know exactily what the problem is and how to solve it.

Can somebody help me? please.

I don’t know how to get it to work.

Thank you very much and best regards

Your title is not very descriptive of the project you are doing. (short) Problems that are ROS related are best asked on ROS answers. Problems that are not ROS related need to be asked somewhere differently all together.

If you maybe rename the topic and give more details you can start a discussion in ROS projects and get people to contribute and help you with minor issues of your project (This is what ROS Discourse is best used for).

Thank you very much and sorry. I’m really new using ROS and my English is not too good. For both reason my question is too poor.

I will try to explain better. I’m the most interested in solving my problem.

Thank you again

Regards

I’m trying to link a Raspberry pi with pycroft with a Turtlebot via SSH. I have created a skill and I want that when I said “go to somewhere” the turtlebot goes to this place.

No problem with this part. The problem come here.

I have a python script and it works fine if firstly I connect via ssh and then I execute python go_to_specific_point_on_map.py

$ ssh tb2@192.168.0.158
$ python go_to_specific_point_on_map.py

Image of everything working fine

But if I tried to do all in one command, I get: ImportError: No module named ‘rospy’

$ ssh tb2@192.168.0.158 python go_to_specific_point_on_map.py

Image of the error. ImportError: No module named rospy

^[Traceback (most recent call last):
  File "./mubita/go_to_specific_point_on_map.py", line 22, in <module>
    import rospy
ImportError: No module named rospy

I have tried the arunp9294’s solution but I get the same error. $ ssh tb2@192.168.0.158 “source ~/.bashrc; python go_to_specific_point_on_map.py”

The file go_to_specific_point_on_map.py is here: go to specific point on map script

I think it is a problem due to .bashrc is not loaded and the alias neither. I don’t know exactily what the problem is and how to solve it.

Can somebody help me? please.

I don’t know how to get it to work.

Thank you very much and best regards

Give a try to ssh tb2@192.168.0.158 bash -c 'python go_to_specific_point_on_map.py'.

If that doesn’t work, post your .bashrc here. Anyways, this is not the best way to use ROS. It’d be better in most cases to install ROS also on your computer and send the command via ROS with ROS_MASTER_URI set to the turtlebot…

I have tried to ssh tb2@192.168.0.158 bash -c 'python go_to_specific_point_on_map.py' but nothing happens.

The screen appears waiting for ever. Here there is a capture of what is happening
Google Photos

I have tried to install ROS in the pycroft but I have had problems too. I have followed these steps.
http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi

At the end of the process I get an error and nothing works. The error is:
“‘boost/tr1/unordered_set.hpp’ file not found”

I though it would be easier to do what I want using SSH but I’m having problems with all the options.

Thank you again and regards

Post the bashrc. It seems there has to be something rotten in there.

Also, if it’s not Raspberry Pi Zero or 1, you’d better go with installing ROS via the package manager as mentioned in http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi#Introduction .

Thenk you again.

The .bashrc file is this:

I can try to install ROS again but I was afraid because I didn’t want to break my mycroft installation.

Thank you very much

You’re not sourcing ros anywhere in the .bashrc …

And don’t fear installing ROS via package manager. It will tell you what’s about to happen when you type sudo apt install ros-kinetic-desktop or so. If you see some packages are about to be deleted, you can always cancel the installation without any harm being done.

In the future, please ask questions on http://answers.ros.org following our support guidelines: http://wiki.ros.org/Support

ROS Discourse is for news and general interest discussions. ROS Answers provides a Q&A site which can be filtered by tags to make sure the relevant people can find and/or answer the question, and not overload everyone with hundreds of posts.