Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 417

Error: bad interpreter: No such file or directory

$
0
0
I am trying to run the following node using rosrun, to send data through my serial port and I get the error: /opt/ros/kinetic/bin/rosrun: /home/spyros/catkin_ws/src/usb_rs232/scripts/serial_connection.py: /opt/bin/python: bad interpreter: No such file or directory /opt/ros/kinetic/bin/rosrun: line 109: /home/spyros/catkin_ws/src/usb_rs232/scripts/serial_connection.py: Success Also, when I compile the code with `catkin_make`, my node isn't on the list of: `Built target [my_node]` The first version of the code (outside ROS-only python script) works fine. I think the problem has to be in the modification of the code, to run it as a ROS node. Do you have any possible solution, or a hint of what might be the problem here? I am new to ROS. I use Ubuntu 16.04, ROS kinetic, Python 2.7 Thanks in advance! #!/opt/bin/python #!/usr/bin/env python import rospy import serial import time from std_msgs.msg import String def serial_connection(): rospy.init_node('serial_connection', anonymous = True) rate = rospy.Rate(10) syxnotita = 0 euros = 0 mesi_gwnia = 0 while not rospy.is_shutdown(): data = [syxnotita, euros, mesi_gwnia] ser = serial.Serial('/dev/ttyUSB0', 9600) print (ser.name) time.sleep(2) while ser.isOpen(): print ("Port Open") for i in range(5): print ('Hola!') ser.write("Hola!\n") time.sleep(1) rate.sleep() ser.close() if __name__ == '__main__': try: serial_connection() except rospy.ROSInterruptException: pass --- Edit: The output is: ls: cannot access '/opt/bin/python': No such file or directory I used the same interpreter (`#!/opt/bin/python`) when I run the python script (outside ROS) from my terminal. Then I added the line `#!/opt/bin/env python` following the steps of the tutorial for python subscriber node.

Viewing all articles
Browse latest Browse all 417

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>