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?
2
Answers
Make sure you activate your virtual environment.
This can be done by executing the activate script in the terminal:
/pathtovenv/venvname/scripts/activate
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: