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:

  1. Open your project folder in VS code or you can use command prompt.
  2. Click on ”terminal” menu in VS Code then click on “new terminal”

3) Run command (inside vs code)

Syntex: py -3 -m venv <environment name>

Ex. py -3 -m venv myproj_env

4) Click on your virtual environment folder on left side and select python.exe inside scripts

5) Now add your specific interpreter with your project rather than global interpreter

6) Click on view and command palette

7) Search for “python select interpreter

8) Select “Enter interpreter path” option

9) Enter python.exe path (your virtual environment name, scripts then python.exe)

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

Leave a Reply

Your email address will not be published. Required fields are marked *