Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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

scripts\activate 

but I get an error message:

"cannot be loaded because the execution of scripts is disabled on this system".

Could this be because I don't carry administrator privileges on my computer?

like image 669
SScode Avatar asked Sep 10 '13 07:09

SScode


People also ask

How do I enable virtualenv in Windows?

Setting up virtualenv This can be done by activating the activate script in the Scripts folder. The following command creates an activate. bat batch file after activation. This creates an activate.

How do I know if virtualenv is activated?

Check the $VIRTUAL_ENV environment variable. The $VIRTUAL_ENV environment variable contains the virtual environment's directory when in an active virtual environment. Once you run deactivate / leave the virtual environment, the $VIRTUAL_ENV variable will be cleared/empty.


1 Answers

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 PowerShell window. This would allow running virtualenv in the current PowerShell 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.

like image 113
Kamiccolo Avatar answered Sep 30 '22 06:09

Kamiccolo