The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python virtual env error: Activate.ps1 cannot be loaded... FullyQualifiedErrorId : UnauthorizedAccess
By Guest on 24th November 2022 11:08:55 PM | Syntax: PYTHON | Views: 346



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. Problem activating virtual environment on Windows 10:
  2.  
  3. # Create virtual env: python -m venv venv
  4. # Activate the virtual env: . venv/Scripts/activate
  5.  
  6. PS C:\projects\docker\fastapi-docker> . venv/Scripts/activate
  7. . : File C:\projects\docker\fastapi-docker\venv\Scripts\Activate.ps1 cannot be loaded because runn
  8. https:/go.microsoft.com/fwlink/?LinkID=135170.
  9. At line:1 char:3
  10. + . venv/Scripts/activate
  11. +   ~~~~~~~~~~~~~~~~~~~~~
  12.     + CategoryInfo          : SecurityError: (:) [], PSSecurityException
  13.     + FullyQualifiedErrorId : UnauthorizedAccess
  14.  
  15. ---
  16.  
  17.  
  18. Solution:
  19.  
  20. PS C:\Users\..> Get-ExecutionPolicy
  21. Restricted
  22.  
  23. PS C:\Users\..> Set-ExecutionPolicy RemoteSigned
  24.  
  25. Execution Policy Change
  26. 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:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
  27. [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
  28. Set-ExecutionPolicy : Access to the registry key
  29. 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution
  30. policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option. To
  31. change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
  32. At line:1 char:1
  33. + Set-ExecutionPolicy RemoteSigned
  34. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35.     + CategoryInfo          : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
  36.     + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
  37.  
  38. ---
  39.  
  40. If you get that error message, it's because you need to start Powershell as Administrator.
  41. This is what the commands and output should look like:
  42.  
  43. PS C:\WINDOWS\system32> Get-ExecutionPolicy
  44. Restricted
  45. PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned
  46.  
  47. Execution Policy Change
  48. 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:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
  49. [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
  50. PS C:\WINDOWS\system32>












Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.

Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.

See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license
  • Recent Pastes