-
Open Command Prompt or PowerShell in Windows.
-
Install virtualenv by typing the following command:
pip install virtualenv
If you don't have pip installed, you can download it from the official website: https://pip.pypa.io/en/stable/installing/
-
Once virtualenv is installed, navigate to the directory where you want to create your virtual environment.
-
Create a new virtual environment by running the following command:
virtualenv env
This will create a new directory called env in your current directory, which will contain the virtual environment.
- Activate the virtual environment by running the following command:
.\env\Scripts\activate
If you're using PowerShell, you'll need to run .\env\Scripts\Activate.ps1 instead.
-
When the virtual environment is activated, you should see its name in your command prompt or PowerShell prompt (e.g. (env) C:\path\to\directory>).
-
You can now install packages and run Python scripts within the virtual environment.
-
When you're done working in the virtual environment, you can deactivate it by running the following command:
deactivate