[bug] Python import could not be resolved for my own module
See original GitHub issuegeneral information
- Linux: Pop!OS 20.04
- ROS 1: Noetic
- ROS extension v0.6.9
- Python extension v2021.10.1200408502-dev
VSCode Version: 1.59.1 Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa Date: 2021-08-19T11:54:37.513Z Electron: 13.1.7 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Linux x64 5.11.0-7620-generic
what is the bug
Importing my local ROS package results in a warning in VSCode, even though the code runs without errors.
MWE: https://github.com/FSund/ros_vscode_issue_example
Repro steps
MWE: https://github.com/FSund/ros_vscode_issue_example
mkdir -p test_ws/src
cd test_ws/src
source /opt/ros/noetic/setup.bash
catkin_init_workspace
git clone https://github.com/FSund/ros_vscode_issue_example
cd ..
catkin build
source devel/setup.bash
code .
- Open either
src/example/test/test.py
orsrc/other_package/src/executable.py
expected behavior
I would not expect the import to give any warnings, since it works when I run the code.
additional context
.vscode/settings.json
{
"python.autoComplete.extraPaths": [
"/home/filip/ros/test_ws/devel/lib/python3/dist-packages",
"/opt/ros/noetic/lib/python3/dist-packages"
]
}
This seems related to #299, but I’m using Python 3.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Import could not be resolved/could not be ... - Stack Overflow
Open the Command Palette ( Ctrl + Shift + P ), then select the Python: Select Interpreter. From the list, select the virtual...
Read more >"Import could not be resolved" for local packages and modules
Steps to reproduce: Create a python package or module; Create a jupyter notebook (.ipynb file); Import created package at step 1 in the...
Read more >ModuleNotFoundError: no module named Python Error [Fixed]
When you try to import a module in a Python file, Python tries to resolve this module in several ways. · As the...
Read more >Import could not be resolved [Pylance] : r/vscode - Reddit
Try to Reload Window. If the error still exists, check if you install the module in your selected interpreter environment.
Read more >importlib — The implementation of import — Python 3.11.1 ...
modules before any loading begins, to prevent recursion from the import. If the loader inserted a module and the load fails, it must...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No updates to share just yet - I have a large pending release of VSCode (0.9.0), then will be looking at issues like this.
@cmuell89 I’m not quite sure why this isn’t working. I need to set up a repro and get some help from my friends on the python extension team - the ROS extension is likely not configuring the project correctly, but not quite sure what’s missing.