ROS not detecting the Python file in docker image
ROS & Python Versions: Noetic (Dockerized), Python 3.8.5
Problem: I am trying to run a python script using rosrun.
bash
rosrun vision vision_main.py
I come across the following error message:
Traceback (most recent call last):
File "/ws/devel/lib/vision/vision_main.py", line 15, in <module>
exec(compile(fh.read(), python_script, 'exec'), context)
File "/ws/src/vision/scripts/vision_main.py", line 5, in <module>
import Road
ModuleNotFoundError: No module named 'Road'
I've verified that the python files are executables (chmod +x). Additionally, if I run the vision_main.py directly via python3, the code runs fine...
python3 vision_main.py
Any idea why this might be happening?
Directory Structure of src:
src/
├── CMakeLists.txt -> /opt/ros/noetic/share/catkin/cmake/toplevel.cmake
└── vision
├── CMakeLists.txt
├── package.xml
└── scripts
├── road.py
└── vision_main.py
Python Code for vision_main.py file:
#!/usr/bin/env python
import sys
import rospy
from road import Road
if __name__ == '__main__':
rospy.init_node('vision_node', anonymous=True)
rd = Road()
rospy.spin()
Please show the
Dockerfile
.It's like you're not
source
-ing thesetup.bash
(correctly) before trying to run your.py
.