Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenv in PowerShell?

There seems to be a problem when virtualenv is used in PowerShell.

When I try to activate my environment in PowerShell like...

env/scripts/activate 

.. nothing happens. (the shell prompt should have changed as well as the PATH env. variable .)

I guess the problem is that PowerShell spawns a new cmd. process just for running the activate.bat thus rendering the changes activate.bat does to the shell dead after it completes.

Do you have any workarounds for the issue? (I'm sticking with cmd.exe for now)

like image 338
utku_karatas Avatar asked Sep 01 '09 23:09

utku_karatas


People also ask

How do I create a virtual env in PowerShell?

To activate the virtual environment, go to the directory where you installed it and run the following command by replacing "env" with your environment name. To install any package make sure the virtual environment is active. Use the following command to install the package.

How do I enable Python in PowerShell?

With your PowerShell command line open, enter python to run the Python 3 interpreter. (Some instructions prefer to use the command py or python3 , these should also work). You will know that you're successful because a >>> prompt with three greater-than symbols will display.

How do I run virtualenv?

To install virtualenv, just use pip install virtualenv . To create a virtual environment directory with it, type virtualenv /path/to/directory . Activating and deactivating the virtual environment works the same way as it does for virtual environments in Python 3 (see above).


1 Answers

The latest version of virtualenv supports PowerShell out-of-the-box.

Just make sure you run:

Scripts\activate.ps1 

instead of

Scripts\activate 

The latter will execute activate.bat, which doesn't work on PowerShell.

like image 179
jsalonen Avatar answered Sep 25 '22 07:09

jsalonen