简体   繁体   中英

Pulumi and Pulumi Azure Native not recognised in VS Code

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.

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.

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"]

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM