Michael Dvornichenko


Issue in PyCharm: PowerShell Script Not Digitally Signed

When opening PyCharm and navigating to the Terminal tab, you might encounter the following error message:

Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

File C:\Users\хххх\PycharmProjects\ххххх\venv\Scripts\activate.ps1 cannot be loaded. The file C:\Users\ххххх\PycharmProjects\ххххххх\venv\Scripts\activate.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and se
tting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess

This error occurs because the activate.ps1 script in your virtual environment is not digitally signed, and the current execution policy in PowerShell prevents the execution of unsigned scripts.

Solution: Changing the PowerShell Execution Policy

To resolve this issue, you need to change the execution policy in PowerShell to allow the running of unsigned scripts. Here are the steps to change the execution policy:

  1. Open PowerShell or Windows Terminal as Administrator
  2. Change the Execution Policy:
    • To allow the execution of unsigned scripts, set the execution policy to RemoteSigned. This allows scripts created on the local computer to be run without being signed, but requires that scripts downloaded from the internet are signed by a trusted publisher.
    • Type the following command and press Enter: Set-ExecutionPolicy RemoteSigned
    • If prompted for confirmation, type Y and press Enter.
  3. Restart PyCharm:
    • Close PyCharm and reopen it. Navigate to the Terminal tab again and try activating the virtual environment. The error message should no longer appear, and the virtual environment should activate successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *