ROS2 Python package only recognized with `colcon build --symlink-install`
I have a ros2 work space with two python packages. Package2 imports package1 with
from package1.helpers import Helper
I set up the setup.cfg
and setup.py
according to the basic ros2 tutorial.
I add an <exec_depend>package1</exec_depend>
to the package.xml
of package2.
When I build the packages with the colcon build --symlink-install
, source install/setup.bash
, I can run package2 and everything works fine.
When I do colcon build
, source install/setup.bash
without using symbolic links, and run package 2, I get the error message: ModuleNotFoundError: No module named 'package1.helpers'
I even tried installing package1 manually with pip, but it is not recognized.
I see that my python package1 is copied into the ros workspace's build
directory, so I would assume, it is there to be recognized.
The ros2 documentation, does not add any insights.
Which step am I missing? I want to be able to load my ros2 python nodes without using the sym-links
You can check your code with these steps, I found it really useful. Maybe it is a missing dependency
ament_python
/rclpy
inpackage1
orpackage2
?the dependencies are correclty set, I tried again with changing from a setup.py based package to a cmake package. with this it works, so I assume it is a problem with the python ros2 configuration
Did you create your package using
catkin_create_pkg
or by manually creating the files? Inpackage1
, did you exporthelpers.py
in the setup.py file?