2

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I've tried selecting multiple interpreters, none of which have worked. Perhaps I'm still choosing the wrong interpreter?
i found that i got this error only in the virtual environment. When i switched to non-virtual execution, there was no error. So something's funky with my virtual environment. It was a different lib, so might not be related.
I resolved this (with a different import) by installing the imported SDK after activating the virtual environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.