ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ImportError: No module named my_package.msg

asked 2014-06-16 02:25:07 -0600

ct2034 gravatar image

updated 2014-06-24 03:41:04 -0600

Hi I have created a package, that contains custom messages. They seem to be compiled correctly. Because I can call

rosmsg package my_package

and get

my_package/Collision

which is correct. But when I try to run a python script that depends on this message like:

from my_package.msg import Collision

I get:

ImportError: No module named my_package.msg

Do you have any Ideas what I am doing wrong?


Some additional Info:

export | grep ROS
declare -x ROS
declare -x ROS_DISTRO="hydro"
declare -x ROS_ETC_DIR="/opt/ros/hydro/etc/ros"
declare -x ROS_MASTER_URI="http://localhost:11311"
declare -x ROS_PACKAGE_PATH="/home/aub-ch/ros/hydro_ws/src:/home/aub-ch/ros/hydro_mynavigationtest/src:/opt/ros/hydro/share:/opt/ros/hydro/stacks"
declare -x ROS_ROOT="/opt/ros/hydro/share/ros"
declare -x ROS_TEST_RESULTS_DIR="/home/aub-ch/ros/hydro_mynavigationtest/build/test_results"

and

echo $PYTHONPATH 
/home/aub-ch/ros/hydro_mynavigationtest/devel/lib/python2.7/dist-packages:/opt/ros/hydro/lib/python2.7/dist-packages
edit retag flag offensive close merge delete

Comments

For clarification: I have set the my_package as dependency in both CMakeLists.txt and package.xml of the package using the message.

ct2034 gravatar image ct2034  ( 2014-06-16 02:28:02 -0600 )edit

Hi al-dev. I added the data. Do I have to add the oder path to the PYTHONPATH as well?

ct2034 gravatar image ct2034  ( 2014-06-24 03:41:52 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-06-24 03:49:07 -0600

ct2034 gravatar image

updated 2014-07-03 06:08:44 -0600

I have a solution.

The package with the message I used was in the folder /home/aub-ch/ros/hydro_ws/src which was added to the ROS_PACKAGE_PATH. But as I used it in another catkin workspace and it was not added to the PYTHONPATH as al-dev pointed out. This was because I edited the ROS_PACKAGE_PATH myself instead of calling source devel/setup.bash

but ->

The PYTHONPATH must include this subpath of a workspace devel/lib/python2.7/dist-packages if you want to use messages out of it.
Thanks for your help!

edit flag offensive delete link more

Comments

this is correct. but i can (again) due to my karma not mark it.

ct2034 gravatar image ct2034  ( 2014-06-24 11:26:47 -0600 )edit

I am not sure I understand if you are suggesting a fix. Should one modify the PYTHONPATH variable to fix the problem? And if so, how should PYTHONPATH be modified?

antonio gravatar image antonio  ( 2015-11-18 07:39:18 -0600 )edit
0

answered 2014-06-17 04:01:57 -0600

al-dev gravatar image

Can you edit your post with the outputs of "export | grep ROS" and "echo $PYTHONPATH" ?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-16 02:25:07 -0600

Seen: 5,295 times

Last updated: Jul 03 '14