Cannot resolve the import of local python file
TypingCat opened this issue · 1 comments
TypingCat commented
Vscode debugger and intellisense have different interpretations of import
.
I'd like to separate the graph class into a new file. However, there was a problem in importing a new file from an existing file. The followings are error messages according to the import method.
from graph import *
- Pylance: Import "graph" could not be resolved
- ROS2: No module named 'graph'
from .graph import *
- Debugger: Attempted relative import with no known parent package
TypingCat commented
https://github.com/finiel/wheel/issues/13#issuecomment-743711514 works for me. In my case,
from waffle_topology.graph import Graph
The imported module is specified to avoid confusion between graph.Node
and rclpy.Node
.