Couldn't find executable named talker.py

asked 2020-07-16 07:21:09 -0600

Raiz Ahmed gravatar image

i am install noetic ros and install python3-rosdep2. But i am clone talker.py form ros github the code is executable. Can anyone help me out.

Talker.py file

import rospy

from std_msgs.msg import String

def talker():

rospy.init_node('talker', anonymous=True)
pub = rospy.Publisher('chatter', String, queue_size=10)
rate = rospy.Rate(10)

while not rospy.is_shutdown():
    hello_str = "hello world %s" % rospy.get_time()
    rospy.loginfo(hello_str)
    pub.publish(hello_str)
    rate.sleep()

if __name__ = '__main__':

    try:

       talker()

    except rospy.ROSInterruptException:
    pass

CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)

project(hello_world)

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs )

catkin_package()

include_directories( ${catkin_INCLUDE_DIRS} )

add_executable(talker src/talker.cpp) target_link_libraries(talker ${catkin_LIBRARIES} )

add_executable(listener src/listener.cpp) target_link_libraries(listener ${catkin_LIBRARIES} )

Error in the terminal

[rosrun] Couldn't find executable named talker.py below /catkin_ws/src/hello_world

[rosrun] Found the following, but they're either not files,

[rosrun] or not executable:

[rosrun] /catkin_ws/src/hello_world/src/scripts/talker.py

edit retag flag offensive close merge delete

Comments

Hi @Raiz Ahmed,

Did you remember to change the executable permissions of the file:

sudo chmod +x talker.py

If that does not work, you can also try, after the catkin_make to source your enviroment.

Weasfas gravatar image Weasfas  ( 2020-07-17 03:15:18 -0600 )edit