Unable to run custom_service_server.py

I did everything exactly as the course tutorial, but unable to run custom_service_server.py with the following message

Traceback (most recent call last):
  File "/home/user/catkin_ws/src/unit_5_services/src/custom_service_server.py", line 4, in <module>
    from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageResponse # you import the service message python classes
ModuleNotFoundError: No module named 'my_custom_srv_msg_pkg'

My service message is successfully created. When I type rossrv list | grep MyCustomServiceMessage, I can see the result


Have you compiled and sourced?

yes, I have… several times

can you see your package in build directory ? Try build again …once by removing build and devel folder in catkin ws.

rm -r -f build devel

I believe that the error might be in the CMakeLists.txt even if
you have not error message about it

is it safe to delete build and devel folder in catkin_ws? will it automatically generated when I call catkin_make?

I’ve checked it several times. I’m sure it is the same as given in the tutorial, except only the CMAKE version is higher.

Please share you CMakeLists.txt and package.xml

It works after I removing build and devel folder and rebuild the whole package. Thanks for all your help.