0

This error occurs in VS code for pip installed modules.

Exception has occurred: ModuleNotFoundError

It was working on all previous days. I believe that i may have deleted a *.pyc file or something to this extent.

If i do pip freeze i can see the module. For example import tweepy could not be resolved, but i can see that it exists in pip freeze tweepy==3.10.0 and i can see with python --version that i have the correct version Python 3.9.0.

If i run the same on IDLE (python3.9) the code works, which leads me to believe that this is a VScode issue, but i cannot tell what this is or how to fix it.

In fact, if i recreate new folders in VS code, the imports work too.

So the quesiton is, how can i identify where (which folder or file) the corruption is or what has caused VS code to break in this way ?

D.L
  • 4,339
  • 5
  • 22
  • 45

2 Answers2

0

One solution (which works) is to recreate all the folders and subfolders.

It is also noted that this is not specific to python as seen here:

https://github.com/Microsoft/vscode/issues/10391

There is also a suggestion here (which is close, but did not resolve the issue):

vscode import error for python module.

I have noticed that if I use File -> Close folder and then File -> Open Folder... and open the project folder again, the errors are gone.

D.L
  • 4,339
  • 5
  • 22
  • 45
  • As there are no other suggestions and this resolves the issue, i have marked this as the correct solution. – D.L Jun 21 '21 at 14:58
0

VStudio may be using a different python interpreter. Just click here and select the proper one:enter image description here

enter image description here

plmk
  • 2,194
  • 1
  • 15
  • 21