3

I removed the virtualenv first and then create it again. By running .\\Envs\automation_cookbook\Scripts\activate.bat as it is mentioned in this post. But the prompt doesn't change at all. I doubt if I'm running it successfully.

PS C:\Users\yashi> rmvirtualenv automation_cookbook

    Deleted C:\Users\yashi\Envs\automation_cookbook

PS C:\Users\yashi> mkvirtualenv automation_cookbook
created virtual environment CPython3.9.0.final.0-64 in 329ms
  creator CPython3Windows(dest=C:\Users\yashi\Envs\automation_cookbook, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\yashi\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.3.1, setuptools==51.0.0, wheel==0.36.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
PS C:\Users\yashi> .\\Envs\automation_cookbook\Scripts\activate.bat
PS C:\Users\yashi> 
PS C:\Users\yashi> lsvirtualenv

dir /b /ad "C:\Users\yashi\Envs"
==============================================================================
automation_cookbook

Edit: I was trying it via virtualenvwrappe

phd
  • 82,685
  • 13
  • 120
  • 165
user8314628
  • 1,952
  • 2
  • 22
  • 46
  • 1
    Probably you figured it out by now ; but for those who come looking like I did ... Your prompt is PowerShell, so you need to activate `YourVenv\Scripts\activate.ps1` not `.bat` – taifwa Apr 01 '22 at 14:56

3 Answers3

8

To make a virtual-environment : python -m venv <env-name>

To activate : Scripts/activate.bat

To deactivate: Scripts/deactivate.bat

To delete : simply delete the folder

1

If you made a virtual environment using python -m venv <env-name> and you are using PowerShell

Then from the same folder, ./<env-name>/Scripts/activate.bat will activate it

and ./<env-name>/Scripts/deactivate.bat will deactivate it.

There will also be ./<env-name>/Scripts/Activate.ps1, but no matching Deactivate.ps1

Lee H
  • 437
  • 1
  • 5
  • 13
1
  1. To create a virtual environment on windows use python -m venv <env_name>
  2. To activate a virtual environment on windows use .\env_name\Scripts\activate.bat **Please note the slashes on windows.
  3. To de-activate a virtual environment on windows use .\env_name\Scripts\deactivate.bat **Please note the slashes
Kaushik Ghosh
  • 11,912
  • 1
  • 15
  • 9