ImportError: cannot import name CustomActionMsgFeedback

Hi

I’m trying to run my quiz for the Actions Server unit. I’m facing the following import error:

ImportError: cannot import name CustomActionMsgFeedback

I had tried also to change this:
" from actions_quiz import CustomActionMsgFeedback, CustomActionMsgResult, CustomActionMsgAction "

to:

" from actions_quiz.msg import CustomActionMsgFeedback, CustomActionMsgResult, CustomActionMsgAction "

but then, I get ImportError: No module named msg

I had followed all steps for creating custom actions, and I don’t know what is wrong. You can check all my code in this gist:

Thank you very much in advanced.

Hi @jesus.perezmartinez,

Thank you for contacting us and welcome to the Community!

Please make the following corrections (if necessary and try again):

  1. Your action message name is named CustomActionMsg.launch. It should be CustomActionMsg.action. Also ensure that this file is inside a subdirectory named action, in your actions_quiz package directory.

  2. The import line should read from actions_quiz.msg .... You cannot import directly from actions_quiz.

  3. Follow this guide to ensure the message is properly compiled: ERROR: Cannot load message class for [package/Message]. Are your messages built?

Hey there,
i have the same problem with the import
i think the structure of my directories is corrrect

grafik
( made the msg directory myself. it is empty and was not created or filled during the catkin_make command)

i build my messages using
catkin_make
source devel/setup.bash

i also get a response searching for the message like this:

user:~/catkin_ws$ rosmsg show actions_quiz/CustomActionMsgAction
->
actions_quiz/CustomActionMsgActionGoal action_goal
std_msgs/Header header
uint32 seq
time stamp
string frame_id
actionlib_msgs/GoalID goal_id
time stamp
string id
actions_quiz/CustomActionMsgGoal goal
string mode
actions_quiz/CustomActionMsgActionResult action_result
std_msgs/Header header
uint32 seq
time stamp
string frame_id
actionlib_msgs/GoalStatus status
uint8 PENDING=0
uint8 ACTIVE=1
uint8 PREEMPTED=2
uint8 SUCCEEDED=3
uint8 ABORTED=4
uint8 REJECTED=5
uint8 PREEMPTING=6
uint8 RECALLING=7
uint8 RECALLED=8
uint8 LOST=9
actionlib_msgs/GoalID goal_id
time stamp
string id
uint8 status
string text
actions_quiz/CustomActionMsgResult result
actions_quiz/CustomActionMsgActionFeedback action_feedback
std_msgs/Header header
uint32 seq
time stamp
string frame_id
actionlib_msgs/GoalStatus status
uint8 PENDING=0
uint8 ACTIVE=1
uint8 PREEMPTED=2
uint8 SUCCEEDED=3
uint8 ABORTED=4
uint8 REJECTED=5
uint8 PREEMPTING=6
uint8 RECALLING=7
uint8 RECALLED=8
uint8 LOST=9
actionlib_msgs/GoalID goal_id
time stamp
string id
uint8 status
string text
actions_quiz/CustomActionMsgFeedback feedback
string feedback

i think this means that the message is build correctly! is this true?
What could then be the source of the error?

Please remove the folder if there’s nothing inside it. It’s not needed and might cause some confusion.

Also,

  • ensure you have run source devel/setup.bash on the terminal on which you’re trying to run the code. Running on one terminal does not work for other terminals; it has to be run on each terminal.
  • check that you are importing the right message (not typo or error in the name).

I got it solved!

The error is caused by the naming of the package and the python file.
If the name is exactly the same except for the .py ending you will have trouble with the imports.
Sometimes the tutorials suggest problematic naming.

1 Like