I can't activate my virtual env in VS Code. I tried same code in the cmd console and it works. But it doesn't work in the VS Code terminal.
This is the command I am trying to run:
D:\python\djangoapp\djangovenv\Scripts\activate.bat
I am using Windows 10 Pro.
You need to switch your Python interpreter to point to the one within your venv when you switch the interpreter VS code it create a .vscode folder within your workspace with a settings.json indicating the python interpreter. This will give VS code the direction of where to locate the venv.
You can follow these steps
Step 1: Enter Ctrl+Shift+P in your vs code.
Step 2: Locate your Virtual Environment:
[
]
Python: select interpreter > Enter interpreter path > Find
Step 3: Once you locate your virtual env select your python version:
your-virtual-env > bin > python3.
Step 4 : Now in your project you will see .vscode directory created open settings.json inside of it and add:
"python.terminal.activateEnvironment": true
don't forget to add a comma before to separate it with the already present key-value pair.
Step 5: Now restart the terminal.
Your virtual environment is activated automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With