skip to Main Content

I have a python project for which I have activated a virtualenv and installed everything in requirements.txt.

This has been done manually through

python -m venv /path/to/new/virtual/environment

and

pip install -r requirements.txt

However the VSCode fails to resolve the additional dependencies (and marks the corresponding imported libraries with a squiggled line as per the screenshot below)

Is there something additional that needs to be configured on VSCode level to make this work?

enter image description here

2

Answers


  1. Make sure you activate your virtual environment.

    This can be done by executing the activate script in the terminal:

    /pathtovenv/venvname/scripts/activate

    Login or Signup to reply.
  2. This was usually caused by python interpreter.

    You could use shortcuts "Ctrl+Shift+P" and type "Python: Select Interpreter" to choose your python interpreter which you installed the package in.

    If you ensure that you’ve chosen the correct python interpereter, you could add the following codes to your settings.json:

    "python.analysis.extraPaths": [
        "/path/to/directory/where/requests/is/installed"
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search