top of page

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 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:

Windows PowerShell

Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements!

File C:\Users\STENGE\PycharmProjects\pythonProject1\venv\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at


+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException

+ FullyQualifiedErrorId : UnauthorizedAccess

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

Check the result of your ExecutionPolicy - here we have "restricted" and we need to change to "RemoteSigned"

PS C:\WINDOWS\system32> Get-ExecutionPolicy


PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned

Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose

you to the security risks described in the about_Execution_Policies help topic at

https:/ Do you want to change the execution policy?

[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Yes

After that, check if your policy changed:

PS C:\WINDOWS\system32> Get-ExecutionPolicy


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

PS C:\Users\diniz\PycharmProjects\pythonProject1> .\venv\Scripts\activate

(venv) PS C:\Users\diniz\PycharmProjects\pythonProject1>

All good!


20 views0 comments

Recent Posts

See All

In this post, I will show you how to install macOS on Windows using VirtualBox hypervisor. #1) You need to install Microsoft Visual C++ on your Windows: #2) Reboot your system. #3) Install VirtualBox:

An aptitude for handling one’s packages is an attribute that any good systems administrator should have. With the recent release of Microsoft’s new Winget tool, package management on Windows has never

bottom of page