Cannot import .msg files from another folder (python)
Hello,
I have the following structure:
Package
|__"src"
|__"node.py"
|__"msg"
|__"message.msg"
|__"__init__.py"
I want to access the message.msg in the node.py, but when I try to import it, I get the pylance error
Import "msg.msg" could not be resolved
I tried
from msg.msg import message.msg
from package.msg import message.msg
import sys
sys.path.append(~/workspace/src/package/msg) #with and without the ~
sys.path.append(package/msg)
And none of it works.
I followed the Creating A Message tutorial and added all the relevant dependencies in the package.xml
and CMakeLists.txt
, and everything also compiles fine.
The init.py is empty
Am I messing up the path?
Asked by WarTurtle on 2021-11-25 04:53:07 UTC
Comments
I'm closing this as a duplicate of #q270568.
That question discusses a similar problem, and I believe the solution offered there should also help you.
If you don't agree, or something is still unclear, edit your question here to clarify why/what doesn't work for you.
Asked by gvdhoorn on 2021-11-25 05:13:04 UTC
Please do not delete questions if they are duplicates and have references to what they are duplicates of.
It's perfectly valid to keep your question around. We should just avoid posting duplicate answers.
Asked by gvdhoorn on 2021-11-25 05:37:42 UTC