'Visual Studio Code: ModuleNotFoundError: No module named 'tensorflow'

Setup: Anaconda3, TensorFlow 2.6.3, cuDNN Archive v8.1.0, CUDA Toolkit 11.2.0, VS Vode 1.64.2

Hello everyone, since the beginning of this week I have problems importing the tensorflow module. After pressing the "Run Python File" button in VS Code I get the following error message (highlighted in red):

error module tensorflow

If I start the Python script "manually" (python test.py) everything works as usual (see picture above. Highlighted in green).

Can recently executed Windows updates cause the problem?

I am grateful for any feedback.

Greetings Chris



Solution 1:[1]

The error is caused by the new Python extension version in vscode:

https://github.com/microsoft/vscode-python/issues/18634

For now, I resolved this issue by switching back to previous version:

https://github.com/microsoft/vscode-python/issues/18639#issuecomment-1060216458

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1