DEV Community

Anoop AK
Anoop AK

Posted on • Edited on

Enabling Python Virtualenv in Windows PowerShell

Virtualenv is one of the most important tools in Python developers' toolkit.
Now that Virtualenv supports PowerShell natively, you can run the script

venv/Scripts/Activate.ps1

which is the equivalent of venv/bin/activate in Linux

However, you might run into the following error when you try to run the script

venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies

You may use Set-Execution Policy to allow the current user to execute scripts as follows

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

That's it! You should now be able to execute Activate.ps1 and get a fully isolated Python development environment for your projects.

Top comments (4)

Collapse
 
mrmoshkovitz profile image
MrMoshkovitz

Thank you :)

Collapse
 
aka_anoop profile image
Anoop AK

Glad it helped 👍

Collapse
 
afey4rce profile image
ABENAMA Franck Emmanuel

Thanks

Collapse
 
mosaablaboune profile image
Mosaab Laboune

Thanks !