VS code error: import "requests" could not be resolved from source

518 views Asked by At

When I try to 'import requests' in my views.py, why is Visual Code Studio throwing this error:

import "requests" could not be resolved from source Pylance

A screenshot of the configuration is here. Any help is greatly appreciated, thank you!

I've checked my interpreter, I've restarted VS code, and I've ensured 'requests' is indeed installed. Yet the VS code error persists.

1

There are 1 answers

1
M69k65y On

I had a similar issue with VS Code recently where installed packages were not being resolved, even after restarting the application multiple times.
I found that the problem is that VS Code started using the wrong virtual environment, even though what was "Recommended" was the correct interpreter. The solution that worked for me was to select the interpreter from the Select Interpreter, overwriting whatever VS Code was using.