How can I activate my virtual environment in visual code terminal? I've tried using the workspace settings method but the settings file was empty
CodePudding user response:
If you have already created your virtual environment, you can just go to its directory by running the following in the VS Code terminal:
cd /python_env/bin/
and then
source ./activate
or, you can directly run
source ./python_env/bin/activate
from your main project directory.
CodePudding user response:
Please follow the steps below:
Open your project folder in VS Code
Create a new terminal
Use the following command in the terminal to create a new virtual environment
# .venv is your virtual environment name # You can also use py -3 -m venv .venv python -m venv .venv
After the virtual environment is generated, use the following command to activate the virtual environment
# .venv is your virtual environment name .venv\scripts\activate
Normally, when VS Code notices that you have created a new virtual environment, a popup will prompt you to allow it to be selected for the workspace.