ModuleNotFoundError: No module named 'requests' using venv in vscode

Brandon Meyer picture Brandon Meyer · Sep 30, 2019 · Viewed 7.9k times · Source

I have 1 file, i get as far as line 1 import requests, nothing more yet and I receive the following error ModuleNotFoundError: No module named 'requests'.

  1. Using Visual Studio Code, installed today with standalone Python x64 3.7.4
  2. Python Extension installed in VSCODE
  3. venv created within VSCODE as a subfolder of workspace withint VSCODE terminal and was recognized by VSCODE when created and I am using venv interpreter in VSCODE as indicated on bottom bar
  4. ran pip install requests within terminal inside VSCODE - completed successfully
  5. ran pip freeze to confirm requests==2.22.0 is registered
  6. Verified pylint was installed in venv

I cannot figure out why VSCODE python interpreter will not recognize that requests is installed

Answer

Nico_Robin picture Nico_Robin · May 16, 2020

Have you checked your user and workspace settings?

Make sure your workspace settings (not your user settings) points to your project's venv path.

I have encountered a similar problem such as yours but was able to solve it by changing the workspace settings python path to point to my venv path as below.

{
    "python.pythonPath": "${workspaceFolder}/code/venv/bin/python"
}