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

Unable to launch a python node using rosrun in ROS-Noetic (Ubuntu20)

asked 2022-06-24 03:37:38 -0500

Ris gravatar image

updated 2023-06-18 09:58:34 -0500

lucasw gravatar image

COMMAND:

rosrun my_robot_tutorial robot_news_radio_transmitter.py   //python publisher node
rosrun my_robot_tutorial smartphone.py    //python subscriber node

ERROR:

/opt/ros/noetic/bin/rosrun: /home/rishav/catkin_ws/src/my_robot_tutorials/scripts/smartphone.py: **usr/bin/env: bad interpreter: No such file or directory**
/opt/ros/noetic/bin/rosrun: line 150: /home/rishav/catkin_ws/src/my_robot_tutorials/scripts/smartphone.py: Success

FILE CONTENT OF smartphone.py:

#!usr/bin/env python3

import rospy
from std_msgs.msg import String 


def callback_receive_radio_data(msg):
    rospy.loginfo("Message received : ")
    rospy.loginfo(msg)

if __name__ == '__main__':
    rospy.init_node('smartphone')

    sub = rospy.Subscriber("/robot_news_radio", String, callback_receive_radio_data)


    rospy.spin()

ISSUE:

This error occurred when I tried to launch the python subscriber node. please give me a solution

edit retag flag offensive close merge delete

Comments

1

Could you please refrain from using CAPITALS everywhere?

I've already removed quite a few (changed them to regular title case), please keep it in mind for next time.

gvdhoorn gravatar image gvdhoorn  ( 2022-06-24 05:46:40 -0500 )edit

yeah sure, I will keep that noted the next time.

Ris gravatar image Ris  ( 2022-06-24 10:30:40 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-06-24 05:44:53 -0500

gvdhoorn gravatar image

updated 2022-06-24 05:49:33 -0500

FILE CONTENT OF smartphone.py:

#!usr/bin/env python3

this is not a correct shebang (and technically also not a ROS problem).

The first line should read:

#!/usr/bin/env python3

note the first /, which is important.

Without it, the path is relative to the current working directory, which for roslaunch would be $ROS_HOME. There most likely isn't an env binary in /home/rishav/.ros/usr/bin.

edit flag offensive delete link more

Comments

Thank you for helping me out. This was a fundamental error which I committed. Thanks again for your time and such a great explanation.

Ris gravatar image Ris  ( 2022-06-24 10:33:37 -0500 )edit

Question Tools

Stats

Asked: 2022-06-24 03:37:38 -0500

Seen: 119 times

Last updated: Jun 24 '22