My_custom_srv_msg_pkg.srv, ImportError: No module named my_custom_srv_msg_pkg.srv

Hi, I have already compiled successfully my_custom_srv_msg_pkg in the exercise 4.3 and found the package
user:~/catkin_ws$ rossrv list | grep MyCustomServiceMessage
my_custom_srv_msg_pkg/MyCustomServiceMessage

but I have given an error Importing the package as in the title. This is part of the code:

#! /usr/bin/env python
import rospy
from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageResponse
from geometry_msgs.msg import Twist
import time

And this is part of the error message:

NODES
/
custom_circle_bb8 (unit_4_services/bb8_move_custom_service_server.py)

ROS_MASTER_URI=http://master:11311

process[custom_circle_bb8-1]: started with pid [3616]
Traceback (most recent call last):
File “/home/user/catkin_ws/src/unit_4_services/src/bb8_move_custom_service_server.py”, line 3, in
from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageResponse
ImportError: No module named my_custom_srv_msg_pkg.srv
[custom_circle_bb8-1] process has died [pid 3616, exit code 1, cmd /home/user/catkin_ws/src/unit_4_services/src/bb8_move_custom_service_server.py __name:=custom_circle_bb8 __log:=/home/user/.ros/log/d389b0e4-04bc-11eb-992c-028fede41e2b/custom_circle_bb8-1.log].
log file: /home/user/.ros/log/d389b0e4-04bc-11eb-992c-028fede41e2b/custom_circle_bb8-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor…
… shutting down processing monitor complete
done

Thanks in advance for any help that i can be given.

2 Likes

Got same issue, got any help yet?

Check your authorization:

@cexuzhengnnopop,

Did you run source devel/setup.bash on the shell where you are launching the code?

I run source devel/setup.bash and unfortunately have the same problem

@bolokangkk
It seems you are trying to import those messages from another package entirely.

If that is the case, you should have added the package my_custom_srv_msg_pkg as a dependency when creating unit_4_services, e.g.

catkin_create_pkg unit_4_services rospy [...other_dependencies] my_custom_srv_msg_pkg

That would have created the needed dependencies for you in CMakeLists.txt and package.xml. You could modify these manually, but because of the possible errors that modifying CMakeLists.txt and package.xml to support this dependency might introduce, I recommend that you recreate the unit_4_services package including this dependency.

Hello i have the exactly same problem. But i dont import those message from another package. And i get the ImportError

I got the same issue here. I followed the exact step in example 4.8 and copied all the code.

Update:
Solved it by cleaning up my packages and redo everything

1 Like

I solved it now. With remove the build and build all packages again.

user:~/catkin_ws$ rm -rf build
user:~/catkin_ws$ catkin_make
user:~/catkin_ws$ source devel/setup.bash

3 Likes

Hi, I am getting the same error as the screenshots shared earlier in the thread. I tried the ‘source devel/setup.bash’, even after doing the remove the build and build all packages (as mentioned by @92felix, it worked out for him).
I even built a new package and in the dependencies of this one, I included the package which contains my custom service files. Still I’m getting the same error that the module doesn’t exist.

Kindly let me know if someone has figured out the issue.

Thank you

Hi, it’s definitely strange that removing your build/ and devel/ folders and compiling again does not work for you, I just tried that and it work. Could you please share your file configuration and the error message that is showing up?

Worked for me, thanks dude!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.