ImportError: cannot import name 'AddTwoInts' from 'beginner_tutorials.srv'

asked 2020-08-31 04:06:13 -0500

Sanjay_KC gravatar image

While going through the tutorial Examining ServiceClients, whenever I execute $ rosrun beginner_tutorials I get the error Traceback (most recent call last): File "/home/sanjay/catkin_ws/devel/lib/beginner_tutorials/", line 15, in <module> exec(compile(, python_script, 'exec'), context) File "/home/sanjay/catkin_ws/src/beginner_tutorials/scripts/", line 5, in <module> from beginner_tutorials.srv import AddTwoInts,AddTwoIntsResponse ImportError: cannot import name 'AddTwoInts' from 'beginner_tutorials.srv' (/home/sanjay/catkin_ws/devel/lib/python3/dist-packages/beginner_tutorials/srv/

I tried $source ./devel/setup.bash after running $catkin_make as per the recommendation from the past answers but still, the error is not resolved.

edit retag flag offensive close merge delete



@Sanjay_KC, I assume you change nothing from the original tutorial code, I am right?. If you change something can you post your versions and Cmake to see if something is not properly implemented?

Weasfas gravatar image Weasfas  ( 2020-09-01 11:52:12 -0500 )edit

@Sanjay_KC, did you solve it? I have the same problem.

bartekpacia gravatar image bartekpacia  ( 2021-01-19 18:44:28 -0500 )edit

Had this exact issue running ROS Noetic on Windows 11 I solved this issue by editing the file : workspace/devel/lib/site-packages/srv/ All generated class names were generated as 'addTwoIntsRequest', 'addTwoInts', etc. when it was expected to be 'AddTwoIntsRequest', 'AddTwoInts', etc. so just change all 'a's in class names and other places to 'A' where it makes sense.

Markus Ruud gravatar image Markus Ruud  ( 2022-08-31 06:57:40 -0500 )edit