Using rosrun breaks python3 import
Hey there,
I'm writing a ROS node in Python and I want to import Classes from a file in the same directory as my node.
When executing the file wit python3, the imports are fine. But when I execute the file using $ rosrun mypackage Node.py
, I get an Error ImportError: cannot import name 'Com' from 'Com' (/home/myname/catkin_ws/devel/lib/mypackagename/Com.py)
(I'm importing the Class Com from the file Com.py).
The Error message shows that it's importing from the /devel/lib/mypackagename/
directory.
So my question is, how do I tell ROS to import the file from the same directory, my node is in?
I'm using ROS Noetic 1.15.11
The node file itself and the file Com.py is in the directory ~/catkin_ws/src/mypackagename/scripts
I'm importing the class as follows: from Com import Com
Thanks in advance!