none none
none none

Reputation: 343

Import could not be resolved with custom library in Visual Studio Code

I have created a myutils.py file, added it to PYTHONPATH via .bashrc, and it correctly gets imported during the actual runtime.

However, when I'm viewing the file that imports the library in Visual Studio Code, it doesn't recognize it and gives me the warning Import "myutils" could not be resolved PylancereportMissingImports.

How do I show Visual Studio Code that I'd like it to cache the contents of my custom module?

Upvotes: 1

Views: 1100

Answers (2)

Molly Wang-MSFT
Molly Wang-MSFT

Reputation: 9521

In settings.json file you have to add the paths from which folder you import myutils:

"python.analysis.extraPaths": [
    "<path to the folder that contains myutils.py>",
]

Upvotes: 1

user15256253
user15256253

Reputation:

Choosing the interpreter might help solve the problem.

enter image description here

Upvotes: 1

Related Questions