Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This issue is not even related to ROS but to how Python resolves imports. The problem is that you can not import a package "my_foo" from with a Python file "my_foo.py". In your example the script imports 'itself' and does not "msg" inside of it.

If the script itself is not on the sys.path you can work around the issue by using "from __future__ import absolute_import" (http://www.python.org/dev/peps/pep-0328/). But in the case your script is part of sys.path (which is the case if you e.g. invoke it from within the same folder) you have to make both name different (usually by renaming the script).

This issue is not even related to ROS but to how Python resolves imports. The problem is that you can not import a package "my_foo" from with a Python file "my_foo.py". In your example the script imports 'itself' and does not find "msg" inside of it.

If the script itself is not on the sys.path you can work around the issue by using "from __future__ import absolute_import" (http://www.python.org/dev/peps/pep-0328/). But in the case your script is part of sys.path (which is the case if you e.g. invoke it from within the same folder) you have to make both name different (usually by renaming the script).