I'm using python installed in a loc My file structure is set up as following
adsb_comm
msg
adsb.msg
flarm.msg
flighttracking.msg
src
__init__.py
main.py
test.py
__init__.py
CMakeLists.txt
package.xml
I try to import the messages for my code follows
#!/usr/bin/env python
import rospy
from adsb_comm.msg import adsb, flarm, flightTracking
When writing code, VSC recognizes this perfectly but when I try to run the code, it always results in the following error:
Traceback (most recent call last):
File "/home/joren/catkin_ws/src/adsb_comm/src/main.py", line 5, in <module>
from Parser import adsbMod, flarmMod, statMod
File "/home/joren/catkin_ws/src/adsb_comm/src/test.py", line 3, in <module>
from adsb_comm.msg import adsb, flarm, flightTracking
ImportError: No module named adsb_comm.msg
When I ran
>>> import sys
>>> sys.path
I got
['', '/opt/ros/melodic/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/joren/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/wx-3.0-gtk3']
But I am not certain what to make of this. I also tried using a relative import instead, along the lines of
from ..msg import adsb
but got a value error
ValueError: Attempted relative import in non-package
What could I be missing here?