Community
Halima Abdi
Halima AbdiBusiness
Oct 9

Why is my Python virtual environment not activating after Windows update?

So I was setting up a new laptop for the team and after a Windows update my venv wouldn't activate. I'd run 'python -m venv myenv' then try to activate it, but PowerShell just threw a command not found error. I thought I'd wrecked the environment. Turns out Windows updates sometimes reset execution policies, so scripts won't run by default. The fix was simple: run 'Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser' in PowerShell as admin, then activation worked fine. Saved me hours of debugging.

6

Replies

6
Mark Ochieng
Mark OchiengOct 9

Glad you tracked it down to the execution policy. Windows updates do tend to flip that back to Restricted. One thing to watch: the change only applies to the current user, so if you run PowerShell from another account or as a service you might hit the same issue again. Have you considered setting the policy via Group Policy or a startup script so it sticks?

Esther Nyambura
Esther NyamburaOct 9

Thanks for posting the fix, it's a classic Windows side effect. Just to double-check though, have you run Get-ExecutionPolicy -List to confirm RemoteSigned is actually applied to the CurrentUser scope and isn't being overridden by a stricter LocalMachine or Group Policy setting?

Lydia Achieng
Lydia AchiengOct 10

Oh this is so relatable! I've lost a whole afternoon to the same thing after a Windows update on my personal laptop. For anyone new to this: next time your venv won't activate after an update, just check your execution policy first before you start rebuilding everything. Saves so much stress, especially when you're trying to focus on learning instead of debugging Windows quirks.

AM
AmaniOct 11

Nice catch on the execution policy. Another quick workaround if you don't want to change the global setting is to launch the activation script directly with `powershell -ExecutionPolicy Bypass -File.\myenv\Scripts\Activate.ps1` that lets you bypass the restriction just for that one command.

Samuel Kiptoo
Samuel KiptooOct 11

Good stuff, thanks for sharing this. For anyone in a shared workspace or cyber cafe where you can't touch admin settings, just switch to Command Prompt or Git Bash to activate your venv - those don't have execution policy restrictions at all. Saves you from asking the IT guy for permissions every time Windows updates.

Kevin Mwangi
Kevin MwangiOct 12

Adding to what's been said: the venv itself was never broken, only PowerShell refused to run the script, so no need to delete and rebuild the folder. If it's a shared office laptop where you can't get admin rights, just open Git Bash or plain cmd and activate from there, those don't have an execution policy at all and it works straight away.