[Solved] virtualenv won’t activate on windows

Essentially I cannot seem to activate my virtualenv environment which I create.

I’m doing this inside of windows powershell through using


but get an error message

“cannot be loaded because the execution of scripts is disabled on this

Could this be because I don’t carry admin privileges on my computer?

Enquirer: SScode


Solution #1:

Moving comment to answers section 🙂

According to Microsoft Tech Support it might be a problem with Execution Policy Settings. To fix it, You should try executing Set-ExecutionPolicy Unrestricted -Scope Process (as mentioned in the comment section by @wtsiamruk) in Your Power Shell. This would allow running virtualenv in the current Power Shell session.

There is also another approach that is more unsafe, but recommended by MS Tech Support. This approach would be to use Set-ExecutionPolicy Unrestricted -Force (which do unleash powers to screw Your system up). However, before you use this unsafe way, be sure to check what your current ExecutionPolicy setting is by using get-ExecutionPolicy. Then, when you are done, you can revert back to this ExecutionPolicy by using Set-ExecutionPolicy %the value the get-ExecutionPolicy command gave you% -Force.

Respondent: Kamiccolo

Solution #2:

In powershell use


instead of activate.bat which doesn’t work in powershell anymore.

also deactivate by just typing


at the command prompt

Respondent: Matt N

Solution #3:

Set the ExcutionPolicy for the Process Scope
after Yes [y]
then type Scripts/activate

enter image description here

Respondent: Adil Siddiqui

Solution #4:

On Windows, open Windows PowerShell as Administrator

enter image description here

Set-ExecutionPolicy Unrestricted -Force

create virtual environment

pip install virtualenv
virtualenv foo
cd .foo

enter image description here

Respondent: Do Nhu Vy

Solution #5:

Another quick solution I have found here (it is applicable for Windows Powershell only) is like this:

First run


Then run


At this position, your Virtualenv is activated. Now if you deactivate it and want to activate it again later in the same session of powershell, you just need to run-


There is no need to cmd or activate.bat command later.

Respondent: ni8mr

Solution #6:

Follow these steps to the latter.
step 1. Use Windows PowerShell as ADMINISTRATOR. (VERY IMPORTANT) and cd into the project folder. Run

virtual env

step 2. Check in the scripts folder if you have your activate.bat file

envScriptsactivate.bat #It has to be there.

step 3. If it is not here make sure you have an internet connection and run this again

virtual env 

step 4. If the activate.bat file is there in the script folder proceed.
step 5. run this on your shell

Set-ExecutionPolicy Unrestricted -Force

step 6. To activate virtualenv on Windows, activate script is in the Scripts folder :


step 7 check for the (env) at the start of each line this shows you are on the virtual environment

step 8. To reactivate when yo come back to the project the second time run:

Respondent: Ochieng’

Solution #7:

Open another powershell as admin and then type:

set-executionpolicy remotesigned

Then Press y and then enter.

Now close this powershell and go back to shell you were working with. This will solve the issue.

Respondent: Abhishek Chauhan

Solution #8:

To install a virtual environment in Windows Powershell only but to activate you’ll need to run Windows powershell as Administrator

  1. pip install virtualenv
  2. virtualenv %Name of virtual environment%

It is installed now to activate it, run powershell in as administrator

  1. Set-ExecutionPolicy Unrestricted -Force
  2. .envScriptsactivate

To deactivate the environment

  1. .envScriptsdeactivate

Hope it helps.

For more help do visit the official page

Respondent: Amit Gupta

Solution #9:

in windows you should activate the virtual environment by following command in cmd


if the environment is activated then it show your environment name enclosed with bracket like this

(your_environment) E:your_environmentScripts>

Also we can ensure by checking with where.exe it will list our active python environment with order of hierarchy

 (your_environment) E:your_environmentScripts>where.exe python



if you need to deactivate then do

(your_environment) E:your_environmentScripts>deactivate.bat

Respondent: Janarthanan Ramu

Solution #10:

This worked for me:

You can simply open a normal (you do not need elevated access) cmd or powershell session (I use the embedded PS terminal in vscode) and type the following from the folder where the script file is e.g.: .venvScriptsActivate.ps1:

powershell.exe -executionpolicy unrestricted -command .Activate.ps1 -Scope CurrentUser

and then you can run the activate command after that.

Note: This will only allow that specific Script to run, and only by your logged in user.

Respondent: Ole Aldric

Solution #11:

If you don’t want to change your computer’s execution policy on windows like I do, you can use windows command prompt instead of windows powershell, and just need to run
to activate your env

Respondent: ianNg

Solution #12:

If machine a 64 bit, open the x86 instance of PowerShell as Administrator & check (set) the execution policy.
try this

Set-ExecutionPolicy Unrestricted


Set-ExecutionPolicy Unrestricted -Force
Respondent: yas

Solution #13:

For me on Windows 10 x64
– Open cmd as an Administrator
– powershell
– type Set-ExecutionPolicy Unrestricted -Force

Voila, reOpen VSCode and start pythoninnngg

Respondent: Sami Kalammallah

Solution #14:

Based on the answers found here, I created a short tutorial for this with screenshots.

  • Python 3.7
  • Windows 10 64bits
  • PowerShell

Hope it can help: https://github.com/harrywang/self-contained-project/wiki/How-to-setup-Python-3-virtual-environment-on-Windows-10

Respondent: dami.max

Solution #15:

Delete the directory for that venv you created. And create a new one using the command:

python -m venv myvenv

Then see if the activate command works.

Respondent: Emerson Araujo

Solution #16:

C:path> Set-ExecutionPolicy - Scope CurrentUser

cmdlet Set-ExecutionPolicy at command pipeline position 1
Supply values for the following parameters:
ExecutionPolicy: Unrestricted

C:path> Scriptsactivate.ps1

(new env)

C:path> deactivate


This Worked

Respondent: HarshaV92

Solution #17:

In windows Powershell the ExecutionPolicy is set to ‘restricted’ by default.
This does not allow scripts to be run in Powershell.

We can only run scripts when the ExecutionPolicy is set to ‘RemoteSensing’ from ‘Restricted’
You can follow the following video to do that!

After the above step ; you can directly type “Scrits/activate” (while being in the directory of the virtual environment that you want to activate) to activate the virtual environment that you wish to activate !


Respondent: Ajmal Sheikh

Solution #18:

If you have used pipenv in creating your virtual environment you should run pipenv shell before executing any command in vs code terminal

Respondent: Gimnath

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.