How to activate virtualenv on Windows?

Viewed 4901

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

2 Answers

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

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

Related