2

Problem

VS Code doesn't seem to have recognised either of the following python libraries + no intellisense.

import pulumi
from pulumi_azure_native import resources
from pulumi_azure_native import storage
...

VS Code highlights them with the Import <library> could not be resolved message. Also no suggestions are shown.

Story

I have started creating a Pulumi dev stack and I am wanting to do this in Python. I have initialised a Pulumi project which gives me the following hierarchy:

my-project
   ├─ venv
   ├─ __main.py__
   ├─ .gitignore
   ├─ Pulumi.dev.yaml
   ├─ Pulumi.yaml
   └─ requirements.txt

The modules already installed are pulumi and pulumi-azure-native as shown in the requirements.txt file:

pulumi>=3.0.0,<4.0.0
pulumi-azure-native>=1.0.0,<2.0.0

I have activated the virtual environment in which the above libraries are installed.

2 Answers2

0

Turn to venv\Lib\site-packages and check if module exists.

If yes, add the following in Workspace Settings.json:

"python.analysis.diagnosticSeverityOverrides": {
        "reportMissingImports": "none"
    }

The warning should go away.

UPDATE: Intellisense works well

enter image description here

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • Thanks, This will for sure disable the warning. But what should I do to get intellisense to work? – Faith Baghan Dec 28 '21 at 02:55
  • @FaithBaghan. Not familiar with the module, but typing `pulumi.` indeed follows suggestions like the screenshot in my post – Molly Wang-MSFT Dec 28 '21 at 03:12
  • @FaithBaghan. Turn to settings.json, both user and workspace, check if you add some settings that disable suggestions and intellisense. By the way, i use pylance as python language server. – Molly Wang-MSFT Dec 28 '21 at 03:19
0

the only way I did it work was adding extraPaths to on my settings.json:

{

  "python.analysis.extraPaths": ["/Users/bcarvalho/my-pulumi-project/infrastructure/venv/lib/python3.10/site-packages"]

}