Solution to “Running Scripts Is Disabled On This System” Error On Powershell

1 minute read

I run into this error “running scripts is disabled on this system” as I was trying to activate Python’s virtualenv on Powershell.

running scripts disabled

This error happens because the venv\Scripts\activate command tries to run the Activate.ps1 Powershell script to activate the virtual environment.

Note: .ps1 is an extension for powershell scripts.

It turns out on my Windows 10 system, the Execution Policy is set to restricted by default. This means that Powershell cannot execute any script.

get execution policy

Here is how I fixed the error:

Step 1: Open Windows Powershell as Admin

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 Powershell window where you got the error.

get execution policy

Step 2: Type the following command the new Powershell window:

> set-executionpolicy remotesigned

This command will allow you to run scripts that are on your local computer(unsigned) and remote scripts(from the internet) which have been signed.

Step 3: You will be prompted to run accept the change, type Y(Yes) and press enter on your keyboard to allow the change.

execution policy change

Step 4: Close the Powershell admin window, and then go back to the Powershell Window(where you got the error) and run the command again.

virtualenv works

The command has worked! virtualenv has been activated.

(venv) PS C:\Users\Stanley\django_project>