ModuleNotFoundError 'my_custom_srv_msg_pkg' is not a package

So, after reading all similar topics and trying to get around this myself, I still get

So first, let’s check out if we have a clean build:

rm -rf build

will show me this in one of the lines, which is promising

and we can keep going

source devel/setup.bash
rospack profile

turns out fine and everything should be reset. Let’s check if we have a package:

rospack list | grep my_custom

will give me

my_custom_srv_msg_pkg /home/user/catkin_ws/src/my_custom_srv_msg_pkg

Means the error message on top is at least wrong about the package. Maybe it’s the message, so let’s see:

rossrv show my_custom_srv_msg_pkg/MyCustomServiceMessage

will give me

int32 duration

bool success

So really no surprises here. Maybe a typo anywhere?
shows the IDE’s type aid at least knows where everyting is. Now running

rosrun my_custom_srv_msg_pkg

would still get me

ModuleNotFoundError: No module named ‘my_custom_srv_msg_pkg.srv’; ‘my_custom_srv_msg_pkg’ is not a package

I ran out of ideas.

It turns ot catkin_make doesn’t generate a python file in


Only MyCustomServiceMessage.h MyCustomServiceMessageRequest.h MyCustomServiceMessageResponse.h, maybe that’s the issue.

Make sure that your CMakeLists.txt has rospy, std_msgs and message_generation listed under find_package(catkin REQUIRED COMPONENTS ) it will be in caps make sure it’s also listed in catkin_package CATKIN_DEPENDS . In the package.xml make sure you have <build_depend>message_generation</build_depend>, <build_export_depend>message_runtime</build_export_depend> and <exec_depend>message_runtime</exec_depend>
Finally if this compiles successfully remember to source devel/setup.bash in every terminal you use. Before you start you can also remove your build and devel folders.
rm -rf build/ devel/ then re-build with catkin_make and source devel/setup.bash


It turned out to be this issue: No module named srv - ROS Answers: Open Source Q&A Forum

switching from




since the node name shouldn’t be the same as the package name.

1 Like

hskramer, I had the same problem (error message “No module named ‘my_custom_srv_msg_pkg.srv’; ‘my_custom_srv_msg_pkg’ is not a package”), so I followed your recommendations; I double checked the changes to the CMakeLists.txt and package.xml files, and then removed the build and devel folders using rm -rf build/ devel/. When I tried to rebuild with catkin_make, I got the error:

“CMake Error at /opt/ros/noetic/share/genmsg/cmake/genmsg-extras.cmake:271 (message):
Could not find ‘share/rospy/cmake/rospy-msg-paths.cmake’ (searched in

I think I made a fatal mistake by deleting those folders. I don’t know enough about the catkin building process to know what to do next, so any help would be appreciated. I’m taking the ROS in 5 days course and I’m working on Unit 6, exercise 6.3.

Ray Kimber

Hi, deleting your build/ and devel/ folders is not a fatal mistake. They are generated in the compilation process, so sometimes it’s a good idea to delete them to “start fresh” when weird things are happening with your setup or your nodes. That error message is strange though, and it doesn’t have to do with those folders. Maybe a good idea would be to re-do the package from scratch. Is this issue happening to you still?

I want to highlight a very easy pitfall here. (Well, I made it at least)

I skimmed this in the instructions and inadvertently used message_generation for all three tags which was wrong. The last two tags use message_runtime

1 Like

I can understand where your coming from but you have to remember two things; one It is common practice to put code inside a code block. Two and most importantly if you want to become a ROS developer you must pay attention to the details. Writing a CMake file and a package.xml file involves many subtle details far too many to start highlighting in color.