ROSRUN command not running properly.

asked 2020-08-08 07:21:05 -0500

HASSAN ISMAIL gravatar image

I write a Python script inside the src and code_pkg folder but when i run the rosrun command then following error occured.

robotics@robotics-PC:~/catkin_ws/src/code_pkg$ rosrun code_pkg [rospack] Error: package 'code_pkg' not found

edit retag flag offensive close merge delete


did you run catkin_make and source devel/

plutotx gravatar image plutotx  ( 2020-08-10 09:58:05 -0500 )edit

First move to "catkin_ws" folder. Then as @plutotx mentioned, run


from that folder. next run

source devel/setup.bash

and finally

rosrun code_pkg

try this and post the output you get

KalanaR gravatar image KalanaR  ( 2020-08-11 02:28:31 -0500 )edit

@KalanaR what is the function of Catkin_ make and Source devel/setup.bash Further i run this but not succeded same eroor occurred

HASSAN ISMAIL gravatar image HASSAN ISMAIL  ( 2020-08-11 14:00:43 -0500 )edit

when you are writing in C++ , catkin_make compiles the code and generate required build and devel folders. devel/setup.bash file holds the details about the packages you created inside "catkin_ws". what happens when you source it is, you load all the path variables and other stuff to your terminal (this is what i understand, please correct me if im wrong). which are required to locate your nodes.

when you are writing in python, catkin_make creates build and devel folders but does not compile anything. but again devel contains required paths and other stuff like in C++ case.

this is from rospy tutorial here

*We use CMake as our build system and, yes, you have to use it even for Python nodes. This is to make sure that the autogenerated Python code for messages and services is created. Go to your catkin workspace and run catkin_make:

$ cd ~/catkin_ws
$ catkin_make*
KalanaR gravatar image KalanaR  ( 2020-08-12 10:07:37 -0500 )edit

@HASSAN ISMAIL can you post the terminal output including the commands you used. (may be a image)

KalanaR gravatar image KalanaR  ( 2020-08-12 10:12:37 -0500 )edit