I tried to import the Albumentations package into my ROS 2 workspace with support from rosdep as follows:

1. Init and install rosdep

Details at: Managing Dependencies with rosdep

2. Add dependencies in package.xml of my ROS2 package

My package.xml file:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <description>TODO: Package description</description>
  <maintainer email="[email protected]">root</maintainer>
  <license>TODO: License declaration</license>


3. rosdep install packages

rosdep install --from-paths src --ignore-src -r -y

The output after installing Albumentations successfully:

#All required rosdeps installed successfully

4. Build the package

source /opt/ros/humble/setup.bash
colcon build --merge-install --symlink-install my_package

5. Run the node

After performing the above actions and running the ROS 2 node in my_package, an error still occurs as follows:

import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
import cv2
import torch
import albumentations as A

The output:

File "/workspaces/ROS2_ws/build/my_package/my_package/node.py", line 9, in <module>
    import albumentations as A
ModuleNotFoundError: No module named 'albumentations'

Before installing the Albumentations package, I had successfully installed the PyTorch library in my workspace using the same steps as mentioned above, but it doesn't work with Albumentations.

Please help me overcome this difficult situation. Looking forward to your response. I apologize for being new to using ROS2.

  • $\begingroup$ "The output after installing Albumentations successfully:" It would be very helpful to show how this was installed and where. And how you're including that pip environment in your active one to help you. $\endgroup$
    – Tully
    Sep 16, 2023 at 18:28

1 Answer 1


The most possible problem is your current directory when running rosdep install, if you are in the workspace directory run it with --from-paths src. However, if you are in the src already run it with --from-paths . I tried it on my local machine and it worked so I can't think of any other problem.

  • $\begingroup$ Plus 1 for going through the actual steps as test. $\endgroup$
    – billy
    Sep 17, 2023 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.