I just started working on a Django project. In the beginning, the vscode terminal was working fine and executing the virtual environment created by pipenv for the project, but when I opened the project again, I got this error and was unable to open the virtual environment interpreter.
Error message in Terminal:
PS E:\Work space\Django> & C:/Users/hp/.virtualenvs/Django-aOoBcd7m/Scripts/Activate.ps1
& : File C:\Users\hp.virtualenvs\Django-aOoBcd7m\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system.
For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
& C:/Users/hp/.virtualenvs/Django-aOoBcd7m/Scripts/Activate.ps1
CategoryInfo : SecurityError: (:) [], PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess
how can i fix this ?
I tried to change the ExecutionPolicy to RemoteSigned in powershell after that its working, but is there any other way to fix this.
Hi instead of changing the ExecutionPolicy to RemoteSigned. You can bypass the policy only for that script execution. Try any of the below commands it should work.(Run PowerShell as administrator)
PowerShell -ExecutionPolicy Bypass -File C:/Users/hp/.virtualenvs/Django-aOoBcd7m/Scripts/Activate.ps1
powershell -NoProfile -ExecutionPolicy Bypass -Command { & 'C:\Users\hp\.virtualenvs\Django-aOoBcd7m\Scripts\Activate.ps1' }