How to Setup Python virtual Environment on Windows
Virtual environment is helpful if you want to run your project with different – different versions, for that you can create 2 different virtual environments for your projects.
Steps:
- Open your project folder in VS code or you can use command prompt.
- Click on ”terminal” menu in VS Code then click on “new terminal”
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-2.png)
3) Run command (inside vs code)
Syntex: py -3 -m venv <environment name>
Ex. py -3 -m venv myproj_env
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-3.png)
4) Click on your virtual environment folder on left side and select python.exe inside scripts
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-4.png)
5) Now add your specific interpreter with your project rather than global interpreter
6) Click on view and command palette
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-5.png)
7) Search for “python select interpreter
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-6.png)
8) Select “Enter interpreter path” option
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-7.png)
9) Enter python.exe path (your virtual environment name, scripts then python.exe)
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-8.png)
10) Now for go in virtual environment run activate.bat file using cmd command
Syntax: yourenv/Scripts/ activate.bat
cmd: myproj_env\Scripts\activate.bat
![](https://blogshub.co.in/wp-content/uploads/2023/12/image-9.png)