question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Python import could not be resolved for my own module

See original GitHub issue

general 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

2021-09-07_13-18

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 or src/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:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ooeyguicommented, Oct 3, 2022

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.

1reaction
ooeyguicommented, Apr 15, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found