ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

"ImportError no module named" error when package with msg also has and installed

asked 2017-05-01 20:14:27 -0600

lucasw gravatar image

updated 2020-11-21 12:16:48 -0600

I have a package with a foo.msg and a python module my_package/src/my_package/ that works fine in the devel space- I can import the msg or alternatively import the python module just fine. But after running catkin_make install the I get an import error:

catkin_make install
source devel/setup.bash
>>>> from mypackage.msg import Foo
>>>>  # (no error output, worked fine)
source install/setup.bash
>>>> from mypackage.msg import Foo
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
Import Error: No module named my_package.msg

I commented out the catkin_python_setup from the CMakeLists.txt and rebuilt (rm -rf build devel install followed by source /opt/ros/jade/setup.bash seems safest which maybe ought to become the topic of another question...), then the import works fine.

One thing I notice is that the module is installed into install/lib/python2.7/dist-packages/my_package, and there are no files in that directory, only one directory lower in msg (it contains and and pyc versions).

This is jade with Ubuntu 14.04.

edit retag flag offensive close merge delete


Actually now that I try it the importing of bar isn't working in the devel space either, so that being configured wrong may be a component of the problem.

lucasw gravatar image lucasw  ( 2017-05-01 20:18:18 -0600 )edit

my_package/src/my_package/ was missing, added it and now this works: from import bar

lucasw gravatar image lucasw  ( 2017-05-01 20:21:44 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-01 20:28:56 -0600

lucasw gravatar image

updated 2017-05-02 10:08:52 -0600

The answer is to make sure that my_package/src/my_package/ exists, otherwise it can't import that module but also screws up msg modules from the same package when installed.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-05-01 20:14:27 -0600

Seen: 1,971 times

Last updated: May 02 '17