Reputation: 408
I have an issue running the Debug environment for Django application in VS-code:
my python is not in the virtual environment, while my django is.
Therefore, the solution I see everywhere with adding to the launch.json settings the line "pythonPath": "${workspaceRoot}/.venv/bin/python2.7",
does not fit, and I end up having the following error:
Exception has occurred: ImportError
Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable?
Did you forget to activate a virtual environment?
When working on the application, I launch the setting environement using the following command:
.\venv\Scripts\activate.ps1
Can anyone help me out to declare my virtual environment the proper way in the launch.json file?
Upvotes: 1
Views: 2455
Reputation: 408
Based on the suggestion of https://stackoverflow.com/users/13877794/omid, I was able to find the solution:
I opened command palette, chose Python: select Interpreter
, and then after selecting the workspace I was interested in, I typed in .\venv\Scripts\python.exe
which works fine for me.
Upvotes: 1
Reputation: 842
if you've created a virtual env lets say with python -m venv my_env
, you should "select Interpreter" and define a path like this:
./my_env/bin/python
make sure you choose correct version (python2/3) and usually there's no need to make launch.json manually.
Upvotes: 0