user8314628
user8314628

Reputation: 2042

How to activate virtualenv on Windows?

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

Upvotes: 4

Views: 25123

Answers (3)

Kaushik Ghosh
Kaushik Ghosh

Reputation: 15030

  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

Upvotes: 2

Lee H
Lee H

Reputation: 467

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

Upvotes: 1

8C AYAAN MUSTAFA
8C AYAAN MUSTAFA

Reputation: 101

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

Upvotes: 9

Related Questions