Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to import Python modules to my node?

I am using ROS Kinetic with Ubuntu 16.04 LTS.

I am trying to connect two ROS nodes (publisher/subscriber, both of them). In one Python node, I am trying to use some modules I had already programmed, which are embedded in pyib2c module.

import pyib2c

This module also imports some Python modules. When I try to run my node, I receive the following error:

ImportError: cannot import name XXXXX , where XXXXX are the modules imported by my pyib2c module.

I have already uncommented the * catkin_python_setup() * in the CMakeList of my package. The setup.py is:

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

# fetch values from package.xml
setup_args = generate_distutils_setup(
    packages=['pyib2c'],
    package_dir={'': 'src'})

setup(**setup_args)

I have also created a __init.py__ file which is:

 from . import tabulate
 from . import pyib2c

My Python node, the module pyib2c, the __init.py__ and the setup.py are them all at the same level in my_package/src. However, it turns out to display the same mistake if I keep the pyib2c in a src folder.

How can I make my node import the modules I need?