Importing python module from another ROS package setup.py
Hi
I am trying to import a python module from another ROS package.
My package is utils
utils
-----/src
------------file_io.py (python module)
------------__init__.py
I have a node in Package A that wants to import a function in file_io.py
So far I have created a setup.py file for the package utils
## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD
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=['utils'],
package_dir={'': 'src'},
requires=['roscpp', 'rospy', 'tf']
)
setup(**setup_args)
In my cmakeList file I made the following changes
install(PROGRAMS src/file_io.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
and uncommented #catkin_python_setup()
In the package.xml of package A, I made the utils package a build and run dependency, modified the cmakList of package A and added the package utils to the find_package(catkin required COMPONENTS).
from utils.file_io import extractor results in the import error: No module name file_io.
Am I missing something? To be honest I did not really understand the tutorial, I am kind of new to python.
As I understand in order to import a python module it has to be in your python path, I thought this setup thing was meant to make ROS automatically add the files to the python path of any package that depends on utils...