Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If PowerShell blocks a Python virtual environment’s Activate.ps1 script, first check which execution-policy scope is effective. Python documents a user-scoped fix: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. You can also skip activation and run the venv’s Python interpreter directly.

Check the effective policy before changing it

In PowerShell, inspect the effective policy and the configured values for each scope:

Get-ExecutionPolicy
Get-ExecutionPolicy -List

Microsoft’s Get-ExecutionPolicy documentation explains that the list shows policy settings by scope. When Group Policy has not defined a policy, Process takes precedence over CurrentUser, which takes precedence over LocalMachine. MachinePolicy and UserPolicy are managed by Group Policy and override local settings.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This matters if a policy-setting command appears to succeed but the effective policy does not change: a higher-precedence scope may be controlling the result. If the list shows MachinePolicy or UserPolicy, ask your device administrator for help. A local setting cannot override an organization-managed policy.

#1 Best Overall
Sale
PowerShell for Sysadmins: Workflow Automation Made Easy
  • Book - powershell for sysadmins: workflow automation made easy
  • Language: english
  • Binding: paperback

Choose the appropriate scope

CurrentUser: Python’s documented user-level fix

To allow locally created scripts to run under RemoteSigned for your Windows user account, enter:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Python’s venv documentation identifies this command as a change that may be necessary to enable the Windows PowerShell activation script. CurrentUser persists for that user until changed; it does not require changing the policy for every user on the machine.

Process: a temporary change for this PowerShell session

If you want the setting to last only for the current PowerShell process and its child processes, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

The change ends when that PowerShell process closes. Use CurrentUser instead if you want Python’s documented user-level setting.

LocalMachine: usually unnecessary for a personal venv

LocalMachine applies to all users and requires elevation on Windows. A personal venv activation problem generally does not require changing it.

Activate the virtual environment

For a virtual environment in a folder named .venv, run this from the project directory:

& ..venvScriptsActivate.ps1

The ampersand invokes the script at that path. If your environment has a different folder name or location, substitute its path. Python documents the general Windows PowerShell activation path as <venv>ScriptsActivate.ps1.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Activation prepends the environment’s scripts directory to PATH. Afterward, typing python in that PowerShell session runs the venv’s interpreter.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand what RemoteSigned allows

RemoteSigned permits locally written scripts that are not marked as downloaded from the internet and requires trusted signatures for downloaded scripts. That policy does not prove that any particular script is safe. Microsoft describes execution policy as a safety feature that helps prevent unintended script execution, while noting that “The execution policy isn’t a security boundary, it’s defense in depth.”

Avoid using Bypass as the routine fix for activating a local venv: it removes warnings and blocks broadly. Microsoft describes Bypass as appropriate for configurations where PowerShell is part of a larger application with its own security model, not as the standard developer workaround.

Run the venv without activating it

Activation is optional. To check the interpreter in a .venv directory directly, run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
..venvScriptspython.exe --version

You can likewise invoke that interpreter by its full path when running Python commands, and run scripts installed in the environment without activating it. Because a venv uses absolute interpreter paths, it is generally not portable; if you move its directory, recreate the environment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.