0
$\begingroup$

Rosanswers logo

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

Originally posted by ct2034 on ROS Answers with karma: 862 on 2014-06-16

Post score: 0


Original comments

Comment by ct2034 on 2014-06-16:
For clarification: I have set the my_package as dependency in both CMakeLists.txt and package.xml of the package using the message.

Comment by ct2034 on 2014-06-24:
Hi al-dev. I added the data. Do I have to add the oder path to the PYTHONPATH as well?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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!


Originally posted by ct2034 with karma: 862 on 2014-06-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ct2034 on 2014-06-24:
this is correct. but i can (again) due to my karma not mark it.

Comment by antonio on 2015-11-18:
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?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.