VSCode Pylance shows [reportMissingImports] while importing some of tensorflow submodules

206 Views Asked by At

I'm using conda environment in vscode. TensorFlow is installed and can be used properly. But Pylance show [reportMissingImports] in some of imported submodules or classes, etc. For example, refer to the screenshot at https://i.stack.imgur.com/VcVOS.png

The squiggled submodules couldn't be resolved by Pylance, and the intellisense and autocompletion are invalid, which is very disruptive to coding. In contrast, the unsquiggled modules, just like tf and keras in the screenshot, work well.

Version Lists
python 3.10.13
TensorFlow 2.11.1
vscode 1.84.2
Pylance 2023.11.10

I have confirmed that I choose the right Python interpreter. Actually, TensorFlow works well while running my codes. I notice that when I type import tensorflow.python. the autocompletion only shows keras submodule. Please refer to the screenshot at https://i.stack.imgur.com/uqRn5.png

Is Pylance bugged, or should anything else be set to ensure Pylance works as expected?

1

There are 1 best solutions below

0
On

Finally, I found the resolution according to https://github.com/microsoft/pylance-release/issues/734. As the screenshot https://i.stack.imgur.com/yksy2.png, it does work well, as my expect.