Running scripts is disabled on this system.
The error occurs because the
venv\Scripts\activate command attempts to run the
Activate.ps1 PowerShell script to activate the virtual environment on the system.
Note: .ps1 is an extension for Microsoft PowerShell scripts.
How to fix the issue? Use the `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned` command to solve the error.
On Windows system, the Execution Policy is set to restricted by default. This means that PowerShell cannot execute any script.
PowerShell has security features built-in, including an execution policy that controls the conditions under which scripts and configuration can be run. This Execution Policy in PowerShell is designed to prevent malicious scripts from running on your system.
Below is the list of four different execution policies in PowerShell –
- Restricted – No scripts can be run.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher.
- Unrestricted – All Windows PowerShell scripts can be run.
You can also use
Set-ExecutionPolicy Unrestricted to remove all restrictions on your security policy (However, the RemoteSigned execution policy is ideal!).
The following steps show you how to fix the error.
Open Windows PowerShell as Administrator
Open the Start Menu on Windows and search for powershell and right-click on it. Click on “Run as administrator”.
Note: You don't need to close the previous PowerShell window where you got the error.
Allow Windows PowerShell to Execute Scripts
To fix the error, you need to change the PowerShell execution policy to
remotesigned. This will allow you to run scripts that are on your local computer unsigned, as well as remotely signed scripts from the internet.
Type the following command in the PowerShell window and press
Enter to change the execution policy:
You will be prompted to accept the change. Type “A (Yes to all)” and press “ENTER” on your keyboard to allow the change.
Close the PowerShell window, and return to the PowerShell Window where the error occurred.