Skip to content

Windows: error when running environment activation script due to execution policy #1341

@MaddyGuthridge

Description

@MaddyGuthridge

Hi. I teach a course where students use VS Code to write and run Python executables. We've noticed that for students with recent Windows installations, the default execution policy has changed, causing this extension's attempts to activate their virtual environments to fail.

& : File C:\\Users\\me\\COMP1010\\Lab\\Week 3\\word_groups_starter\\.venv\\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\\me\\COMP1010\\Lab\\W …
  + CategoryInfo          : SecurityError: (:) [], PSSecurityException
  + FullyQualifiedErrorId : UnauthorizedAccess

While it would technically be possible to make students disable the execution policy by running Set-ExecutionPolicy -ExecutionPolicy Unrestricted in an administrator terminal, this is far from an ideal solution, as we do not want to encourage our students to perform actions that will reduce the security of their systems.

A better solution would be for this extension to run the script in such a way that the execution policy is bypassed, for example using these instructions from the Microsoft documentation.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions