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

Revision history [back]

Just to have this question marked as answered: from the discussion above, it became clear that the hashbang (#!) at the beginning of the Python file was not properly entered. It turns out there was an extra space before the # character.

For anyone reading this in the future, remember, there are 2 required steps to make any Python script run as a ROS node (or even more generally to make the script executable):

  1. The script must be executable by your user. This is typically done with chmod gu+x. I think this is a good tutorial on Linux permissions.
  2. You need to have a hashbang as the first 2 characters of the script to tell the OS which interpreter should interpret the script. This must be the very first 2 characters in the script. For Python we usually use #!/usr/bin/env python.

Just to have this question marked as answered: from the discussion above, it became clear that the hashbang (#!) at the beginning of the Python file was not properly entered. It turns out there was an extra space before the # character.

For anyone reading this in the future, remember, there are 2 required steps to make any Python script run as a ROS node (or even more generally to make the script executable):

  1. The script must be executable by your user. This is typically done with chmod gu+x. I think this is a good tutorial on Linux permissions.
  2. You need to have a hashbang hashbang as the first 2 characters of the script to tell the OS which interpreter should interpret the script. This must be the very first 2 characters in the script. For Python we usually use #!/usr/bin/env python.. The Wikipedia page on this is a good resource: https://en.wikipedia.org/wiki/Shebang_(Unix)