"ImportError no module named" error when package with msg also has setup.py and installed
I have a package with a foo.msg and a python module my_package/src/my_package/bar.py 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
python
>>>> 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 bar.py is installed into install/lib/python2.7/dist-packages/my_package, and there are no __init__.py files in that directory, only one directory lower in msg (it contains __init__.py and _Foo.py and pyc versions).
This is jade with Ubuntu 14.04.
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.my_package/src/my_package/ was missing __init__.py, added it and now this works: from my_package.bar import bar