virtualenv in PowerShell?












22















Hi fellow pythonistas, 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)










share|improve this question





























    22















    Hi fellow pythonistas, 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)










    share|improve this question



























      22












      22








      22


      8






      Hi fellow pythonistas, 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)










      share|improve this question
















      Hi fellow pythonistas, 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)







      python powershell virtualenv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 2 '09 at 2:36







      utku_karatas

















      asked Sep 1 '09 at 23:03









      utku_karatasutku_karatas

      4,18733450




      4,18733450
























          7 Answers
          7






          active

          oldest

          votes


















          7














          Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.



          Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.






          share|improve this answer


























          • Thank you Vinay, clearly explains the issue.

            – utku_karatas
            Sep 2 '09 at 2:38











          • This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

            – Mike Caron
            Apr 5 '11 at 14:59






          • 2





            This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

            – Jorge Vargas
            Mar 14 '14 at 21:45











          • the link goes to 404 page

            – Richard Rich Steinmetz
            Aug 30 '18 at 8:10











          • Link is missing

            – AbhimanyuAryan
            Oct 8 '18 at 4:05



















          59














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



          Just make sure you run:



          Scriptsactivate.ps1


          instead of



          Scriptsactivate


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






          share|improve this answer





















          • 27





            You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

            – Alex L
            Dec 22 '12 at 8:29











          • and simply type deactivate to undo

            – Vadim K
            May 4 '17 at 13:35











          • Is there a way to change the color of the prompt using this approach?

            – null_pointer
            Jun 4 '17 at 3:59











          • null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

            – np8
            Jun 28 '17 at 8:23






          • 1





            Note that the script creates an in memory function for deactivation. It's named deactivate.

            – jpmc26
            Nov 20 '18 at 21:14



















          14














          A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:



          PS C:my_cool_envScripts> cmd
          Microsoft Windows [Version 6.1.7600]
          Copyright (c) 2009 Microsoft Corporation. All rights reserved.

          C:my_cool_envScripts>activate.bat
          (my_cool_env) C:my_cool_envScripts>





          share|improve this answer
























          • This worked for me. So much easier. Thanks!

            – irene
            Aug 9 '17 at 11:07











          • It works, but not maximum

            – Aminah Nuraini
            Jul 10 '18 at 1:46



















          3














          This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:



          set-executionpolicy remotesigned



          for more:
          http://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/






          share|improve this answer































            3














            Inside of the Scripts directory of your virtual environments folder there are several activation scripts that can be used depending on where you are executing the command. If you are trying to activate your virtual env from the Windows PowerShell, try using the following command:



            . .envScriptsactivate.ps1



            In the event you receive an error about the activation script being disabled on your system, you will first need to invoke an execution policy change on your system. This will need to be done as the administrator.



            To do this:



            1) Right click on the PowerShell application and select Run as Administrator



            2) Run the following command: Set-ExecutionPolicy Unrestricted



            3) Rerun the activation command: . .envScriptsactivate.ps1






            share|improve this answer































              2














              try this:
              . .envScriptsactivate.ps1
              watch dots and spaces






              share|improve this answer



















              • 1





                .[my-venv]Scriptsactivate.ps1 worked for me.

                – Josh Usre
                Mar 31 '16 at 18:28



















              0














              I wrote this quick little script to handle my activation and startup of a dev server.



              $ep = Get-ExecutionPolicy

              if ($ep -eq 'RemoteSigned') {

              $root = "C:UsersALevenOneDrive!code_projects!django_projects"

              $test = Read-Host -Prompt 'Would you like to activate the python environment? y/n'
              if ($test -eq 'y') {

              $activatestr = ($root + "work_venvScriptsActivate.ps1")
              & $activatestr

              }

              $test = Read-Host -Prompt 'Would you like to run the python server? y/n'

              if ($test -eq 'y') {

              $whichserver = Read-Host -Prompt 'Enter the name of the project.'
              $path = ($root + $whichserver)
              $runserverstr = ($path + "manage.py")
              python.exe $runserverstr runserver

              }

              } else {

              Write-host "Execution Policy does not allow this script to run properly"
              Write-host "If you have the proper permissions,"
              Write-Host "Please close powershell,"
              Write-host "then right click the powershell icon and run as administrator"
              Write-host "Once in the powershell environment, execute the following:"
              Write-host "Set-ExecutionPolicy RemoteSigned -Force"

              }


              Enjoy.






              share|improve this answer

























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1365081%2fvirtualenv-in-powershell%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                7 Answers
                7






                active

                oldest

                votes








                7 Answers
                7






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                7














                Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.



                Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.






                share|improve this answer


























                • Thank you Vinay, clearly explains the issue.

                  – utku_karatas
                  Sep 2 '09 at 2:38











                • This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                  – Mike Caron
                  Apr 5 '11 at 14:59






                • 2





                  This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                  – Jorge Vargas
                  Mar 14 '14 at 21:45











                • the link goes to 404 page

                  – Richard Rich Steinmetz
                  Aug 30 '18 at 8:10











                • Link is missing

                  – AbhimanyuAryan
                  Oct 8 '18 at 4:05
















                7














                Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.



                Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.






                share|improve this answer


























                • Thank you Vinay, clearly explains the issue.

                  – utku_karatas
                  Sep 2 '09 at 2:38











                • This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                  – Mike Caron
                  Apr 5 '11 at 14:59






                • 2





                  This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                  – Jorge Vargas
                  Mar 14 '14 at 21:45











                • the link goes to 404 page

                  – Richard Rich Steinmetz
                  Aug 30 '18 at 8:10











                • Link is missing

                  – AbhimanyuAryan
                  Oct 8 '18 at 4:05














                7












                7








                7







                Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.



                Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.






                share|improve this answer















                Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.



                Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 24 '18 at 3:33

























                answered Sep 1 '09 at 23:15









                Vinay SajipVinay Sajip

                70.3k8128143




                70.3k8128143













                • Thank you Vinay, clearly explains the issue.

                  – utku_karatas
                  Sep 2 '09 at 2:38











                • This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                  – Mike Caron
                  Apr 5 '11 at 14:59






                • 2





                  This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                  – Jorge Vargas
                  Mar 14 '14 at 21:45











                • the link goes to 404 page

                  – Richard Rich Steinmetz
                  Aug 30 '18 at 8:10











                • Link is missing

                  – AbhimanyuAryan
                  Oct 8 '18 at 4:05



















                • Thank you Vinay, clearly explains the issue.

                  – utku_karatas
                  Sep 2 '09 at 2:38











                • This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                  – Mike Caron
                  Apr 5 '11 at 14:59






                • 2





                  This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                  – Jorge Vargas
                  Mar 14 '14 at 21:45











                • the link goes to 404 page

                  – Richard Rich Steinmetz
                  Aug 30 '18 at 8:10











                • Link is missing

                  – AbhimanyuAryan
                  Oct 8 '18 at 4:05

















                Thank you Vinay, clearly explains the issue.

                – utku_karatas
                Sep 2 '09 at 2:38





                Thank you Vinay, clearly explains the issue.

                – utku_karatas
                Sep 2 '09 at 2:38













                This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                – Mike Caron
                Apr 5 '11 at 14:59





                This works, but one can't add the prompt argument. There would have to be an activate.ps1 that could call Write-Host before the prompt is set.

                – Mike Caron
                Apr 5 '11 at 14:59




                2




                2





                This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                – Jorge Vargas
                Mar 14 '14 at 21:45





                This answer is no longer valid as virtualenv supports powershell out of the box as pointed out in stackoverflow.com/questions/1365081/virtualenv-in-powershell/…

                – Jorge Vargas
                Mar 14 '14 at 21:45













                the link goes to 404 page

                – Richard Rich Steinmetz
                Aug 30 '18 at 8:10





                the link goes to 404 page

                – Richard Rich Steinmetz
                Aug 30 '18 at 8:10













                Link is missing

                – AbhimanyuAryan
                Oct 8 '18 at 4:05





                Link is missing

                – AbhimanyuAryan
                Oct 8 '18 at 4:05













                59














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



                Just make sure you run:



                Scriptsactivate.ps1


                instead of



                Scriptsactivate


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






                share|improve this answer





















                • 27





                  You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                  – Alex L
                  Dec 22 '12 at 8:29











                • and simply type deactivate to undo

                  – Vadim K
                  May 4 '17 at 13:35











                • Is there a way to change the color of the prompt using this approach?

                  – null_pointer
                  Jun 4 '17 at 3:59











                • null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                  – np8
                  Jun 28 '17 at 8:23






                • 1





                  Note that the script creates an in memory function for deactivation. It's named deactivate.

                  – jpmc26
                  Nov 20 '18 at 21:14
















                59














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



                Just make sure you run:



                Scriptsactivate.ps1


                instead of



                Scriptsactivate


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






                share|improve this answer





















                • 27





                  You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                  – Alex L
                  Dec 22 '12 at 8:29











                • and simply type deactivate to undo

                  – Vadim K
                  May 4 '17 at 13:35











                • Is there a way to change the color of the prompt using this approach?

                  – null_pointer
                  Jun 4 '17 at 3:59











                • null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                  – np8
                  Jun 28 '17 at 8:23






                • 1





                  Note that the script creates an in memory function for deactivation. It's named deactivate.

                  – jpmc26
                  Nov 20 '18 at 21:14














                59












                59








                59







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



                Just make sure you run:



                Scriptsactivate.ps1


                instead of



                Scriptsactivate


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






                share|improve this answer















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



                Just make sure you run:



                Scriptsactivate.ps1


                instead of



                Scriptsactivate


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







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 4 '12 at 10:54

























                answered Apr 5 '12 at 14:56









                jsalonenjsalonen

                20.4k107295




                20.4k107295








                • 27





                  You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                  – Alex L
                  Dec 22 '12 at 8:29











                • and simply type deactivate to undo

                  – Vadim K
                  May 4 '17 at 13:35











                • Is there a way to change the color of the prompt using this approach?

                  – null_pointer
                  Jun 4 '17 at 3:59











                • null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                  – np8
                  Jun 28 '17 at 8:23






                • 1





                  Note that the script creates an in memory function for deactivation. It's named deactivate.

                  – jpmc26
                  Nov 20 '18 at 21:14














                • 27





                  You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                  – Alex L
                  Dec 22 '12 at 8:29











                • and simply type deactivate to undo

                  – Vadim K
                  May 4 '17 at 13:35











                • Is there a way to change the color of the prompt using this approach?

                  – null_pointer
                  Jun 4 '17 at 3:59











                • null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                  – np8
                  Jun 28 '17 at 8:23






                • 1





                  Note that the script creates an in memory function for deactivation. It's named deactivate.

                  – jpmc26
                  Nov 20 '18 at 21:14








                27




                27





                You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                – Alex L
                Dec 22 '12 at 8:29





                You may need to run set-executionpolicy RemoteSigned to allow scripts to run (mine was set to Restricted before) docs

                – Alex L
                Dec 22 '12 at 8:29













                and simply type deactivate to undo

                – Vadim K
                May 4 '17 at 13:35





                and simply type deactivate to undo

                – Vadim K
                May 4 '17 at 13:35













                Is there a way to change the color of the prompt using this approach?

                – null_pointer
                Jun 4 '17 at 3:59





                Is there a way to change the color of the prompt using this approach?

                – null_pointer
                Jun 4 '17 at 3:59













                null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                – np8
                Jun 28 '17 at 8:23





                null_pointer: The color of the powershell is most easily changed by right-clicking on the navigation bar -> Properties -> Colors.

                – np8
                Jun 28 '17 at 8:23




                1




                1





                Note that the script creates an in memory function for deactivation. It's named deactivate.

                – jpmc26
                Nov 20 '18 at 21:14





                Note that the script creates an in memory function for deactivation. It's named deactivate.

                – jpmc26
                Nov 20 '18 at 21:14











                14














                A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:



                PS C:my_cool_envScripts> cmd
                Microsoft Windows [Version 6.1.7600]
                Copyright (c) 2009 Microsoft Corporation. All rights reserved.

                C:my_cool_envScripts>activate.bat
                (my_cool_env) C:my_cool_envScripts>





                share|improve this answer
























                • This worked for me. So much easier. Thanks!

                  – irene
                  Aug 9 '17 at 11:07











                • It works, but not maximum

                  – Aminah Nuraini
                  Jul 10 '18 at 1:46
















                14














                A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:



                PS C:my_cool_envScripts> cmd
                Microsoft Windows [Version 6.1.7600]
                Copyright (c) 2009 Microsoft Corporation. All rights reserved.

                C:my_cool_envScripts>activate.bat
                (my_cool_env) C:my_cool_envScripts>





                share|improve this answer
























                • This worked for me. So much easier. Thanks!

                  – irene
                  Aug 9 '17 at 11:07











                • It works, but not maximum

                  – Aminah Nuraini
                  Jul 10 '18 at 1:46














                14












                14








                14







                A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:



                PS C:my_cool_envScripts> cmd
                Microsoft Windows [Version 6.1.7600]
                Copyright (c) 2009 Microsoft Corporation. All rights reserved.

                C:my_cool_envScripts>activate.bat
                (my_cool_env) C:my_cool_envScripts>





                share|improve this answer













                A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:



                PS C:my_cool_envScripts> cmd
                Microsoft Windows [Version 6.1.7600]
                Copyright (c) 2009 Microsoft Corporation. All rights reserved.

                C:my_cool_envScripts>activate.bat
                (my_cool_env) C:my_cool_envScripts>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 13 '10 at 19:52









                elliottelliott

                14113




                14113













                • This worked for me. So much easier. Thanks!

                  – irene
                  Aug 9 '17 at 11:07











                • It works, but not maximum

                  – Aminah Nuraini
                  Jul 10 '18 at 1:46



















                • This worked for me. So much easier. Thanks!

                  – irene
                  Aug 9 '17 at 11:07











                • It works, but not maximum

                  – Aminah Nuraini
                  Jul 10 '18 at 1:46

















                This worked for me. So much easier. Thanks!

                – irene
                Aug 9 '17 at 11:07





                This worked for me. So much easier. Thanks!

                – irene
                Aug 9 '17 at 11:07













                It works, but not maximum

                – Aminah Nuraini
                Jul 10 '18 at 1:46





                It works, but not maximum

                – Aminah Nuraini
                Jul 10 '18 at 1:46











                3














                This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:



                set-executionpolicy remotesigned



                for more:
                http://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/






                share|improve this answer




























                  3














                  This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:



                  set-executionpolicy remotesigned



                  for more:
                  http://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/






                  share|improve this answer


























                    3












                    3








                    3







                    This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:



                    set-executionpolicy remotesigned



                    for more:
                    http://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/






                    share|improve this answer













                    This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:



                    set-executionpolicy remotesigned



                    for more:
                    http://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 7 '16 at 9:21









                    sanfiratsanfirat

                    4113




                    4113























                        3














                        Inside of the Scripts directory of your virtual environments folder there are several activation scripts that can be used depending on where you are executing the command. If you are trying to activate your virtual env from the Windows PowerShell, try using the following command:



                        . .envScriptsactivate.ps1



                        In the event you receive an error about the activation script being disabled on your system, you will first need to invoke an execution policy change on your system. This will need to be done as the administrator.



                        To do this:



                        1) Right click on the PowerShell application and select Run as Administrator



                        2) Run the following command: Set-ExecutionPolicy Unrestricted



                        3) Rerun the activation command: . .envScriptsactivate.ps1






                        share|improve this answer




























                          3














                          Inside of the Scripts directory of your virtual environments folder there are several activation scripts that can be used depending on where you are executing the command. If you are trying to activate your virtual env from the Windows PowerShell, try using the following command:



                          . .envScriptsactivate.ps1



                          In the event you receive an error about the activation script being disabled on your system, you will first need to invoke an execution policy change on your system. This will need to be done as the administrator.



                          To do this:



                          1) Right click on the PowerShell application and select Run as Administrator



                          2) Run the following command: Set-ExecutionPolicy Unrestricted



                          3) Rerun the activation command: . .envScriptsactivate.ps1






                          share|improve this answer


























                            3












                            3








                            3







                            Inside of the Scripts directory of your virtual environments folder there are several activation scripts that can be used depending on where you are executing the command. If you are trying to activate your virtual env from the Windows PowerShell, try using the following command:



                            . .envScriptsactivate.ps1



                            In the event you receive an error about the activation script being disabled on your system, you will first need to invoke an execution policy change on your system. This will need to be done as the administrator.



                            To do this:



                            1) Right click on the PowerShell application and select Run as Administrator



                            2) Run the following command: Set-ExecutionPolicy Unrestricted



                            3) Rerun the activation command: . .envScriptsactivate.ps1






                            share|improve this answer













                            Inside of the Scripts directory of your virtual environments folder there are several activation scripts that can be used depending on where you are executing the command. If you are trying to activate your virtual env from the Windows PowerShell, try using the following command:



                            . .envScriptsactivate.ps1



                            In the event you receive an error about the activation script being disabled on your system, you will first need to invoke an execution policy change on your system. This will need to be done as the administrator.



                            To do this:



                            1) Right click on the PowerShell application and select Run as Administrator



                            2) Run the following command: Set-ExecutionPolicy Unrestricted



                            3) Rerun the activation command: . .envScriptsactivate.ps1







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 21 '18 at 17:56









                            zhijazizhijazi

                            311




                            311























                                2














                                try this:
                                . .envScriptsactivate.ps1
                                watch dots and spaces






                                share|improve this answer



















                                • 1





                                  .[my-venv]Scriptsactivate.ps1 worked for me.

                                  – Josh Usre
                                  Mar 31 '16 at 18:28
















                                2














                                try this:
                                . .envScriptsactivate.ps1
                                watch dots and spaces






                                share|improve this answer



















                                • 1





                                  .[my-venv]Scriptsactivate.ps1 worked for me.

                                  – Josh Usre
                                  Mar 31 '16 at 18:28














                                2












                                2








                                2







                                try this:
                                . .envScriptsactivate.ps1
                                watch dots and spaces






                                share|improve this answer













                                try this:
                                . .envScriptsactivate.ps1
                                watch dots and spaces







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Apr 28 '15 at 11:41









                                liuyiheliuyihe

                                969712




                                969712








                                • 1





                                  .[my-venv]Scriptsactivate.ps1 worked for me.

                                  – Josh Usre
                                  Mar 31 '16 at 18:28














                                • 1





                                  .[my-venv]Scriptsactivate.ps1 worked for me.

                                  – Josh Usre
                                  Mar 31 '16 at 18:28








                                1




                                1





                                .[my-venv]Scriptsactivate.ps1 worked for me.

                                – Josh Usre
                                Mar 31 '16 at 18:28





                                .[my-venv]Scriptsactivate.ps1 worked for me.

                                – Josh Usre
                                Mar 31 '16 at 18:28











                                0














                                I wrote this quick little script to handle my activation and startup of a dev server.



                                $ep = Get-ExecutionPolicy

                                if ($ep -eq 'RemoteSigned') {

                                $root = "C:UsersALevenOneDrive!code_projects!django_projects"

                                $test = Read-Host -Prompt 'Would you like to activate the python environment? y/n'
                                if ($test -eq 'y') {

                                $activatestr = ($root + "work_venvScriptsActivate.ps1")
                                & $activatestr

                                }

                                $test = Read-Host -Prompt 'Would you like to run the python server? y/n'

                                if ($test -eq 'y') {

                                $whichserver = Read-Host -Prompt 'Enter the name of the project.'
                                $path = ($root + $whichserver)
                                $runserverstr = ($path + "manage.py")
                                python.exe $runserverstr runserver

                                }

                                } else {

                                Write-host "Execution Policy does not allow this script to run properly"
                                Write-host "If you have the proper permissions,"
                                Write-Host "Please close powershell,"
                                Write-host "then right click the powershell icon and run as administrator"
                                Write-host "Once in the powershell environment, execute the following:"
                                Write-host "Set-ExecutionPolicy RemoteSigned -Force"

                                }


                                Enjoy.






                                share|improve this answer






























                                  0














                                  I wrote this quick little script to handle my activation and startup of a dev server.



                                  $ep = Get-ExecutionPolicy

                                  if ($ep -eq 'RemoteSigned') {

                                  $root = "C:UsersALevenOneDrive!code_projects!django_projects"

                                  $test = Read-Host -Prompt 'Would you like to activate the python environment? y/n'
                                  if ($test -eq 'y') {

                                  $activatestr = ($root + "work_venvScriptsActivate.ps1")
                                  & $activatestr

                                  }

                                  $test = Read-Host -Prompt 'Would you like to run the python server? y/n'

                                  if ($test -eq 'y') {

                                  $whichserver = Read-Host -Prompt 'Enter the name of the project.'
                                  $path = ($root + $whichserver)
                                  $runserverstr = ($path + "manage.py")
                                  python.exe $runserverstr runserver

                                  }

                                  } else {

                                  Write-host "Execution Policy does not allow this script to run properly"
                                  Write-host "If you have the proper permissions,"
                                  Write-Host "Please close powershell,"
                                  Write-host "then right click the powershell icon and run as administrator"
                                  Write-host "Once in the powershell environment, execute the following:"
                                  Write-host "Set-ExecutionPolicy RemoteSigned -Force"

                                  }


                                  Enjoy.






                                  share|improve this answer




























                                    0












                                    0








                                    0







                                    I wrote this quick little script to handle my activation and startup of a dev server.



                                    $ep = Get-ExecutionPolicy

                                    if ($ep -eq 'RemoteSigned') {

                                    $root = "C:UsersALevenOneDrive!code_projects!django_projects"

                                    $test = Read-Host -Prompt 'Would you like to activate the python environment? y/n'
                                    if ($test -eq 'y') {

                                    $activatestr = ($root + "work_venvScriptsActivate.ps1")
                                    & $activatestr

                                    }

                                    $test = Read-Host -Prompt 'Would you like to run the python server? y/n'

                                    if ($test -eq 'y') {

                                    $whichserver = Read-Host -Prompt 'Enter the name of the project.'
                                    $path = ($root + $whichserver)
                                    $runserverstr = ($path + "manage.py")
                                    python.exe $runserverstr runserver

                                    }

                                    } else {

                                    Write-host "Execution Policy does not allow this script to run properly"
                                    Write-host "If you have the proper permissions,"
                                    Write-Host "Please close powershell,"
                                    Write-host "then right click the powershell icon and run as administrator"
                                    Write-host "Once in the powershell environment, execute the following:"
                                    Write-host "Set-ExecutionPolicy RemoteSigned -Force"

                                    }


                                    Enjoy.






                                    share|improve this answer















                                    I wrote this quick little script to handle my activation and startup of a dev server.



                                    $ep = Get-ExecutionPolicy

                                    if ($ep -eq 'RemoteSigned') {

                                    $root = "C:UsersALevenOneDrive!code_projects!django_projects"

                                    $test = Read-Host -Prompt 'Would you like to activate the python environment? y/n'
                                    if ($test -eq 'y') {

                                    $activatestr = ($root + "work_venvScriptsActivate.ps1")
                                    & $activatestr

                                    }

                                    $test = Read-Host -Prompt 'Would you like to run the python server? y/n'

                                    if ($test -eq 'y') {

                                    $whichserver = Read-Host -Prompt 'Enter the name of the project.'
                                    $path = ($root + $whichserver)
                                    $runserverstr = ($path + "manage.py")
                                    python.exe $runserverstr runserver

                                    }

                                    } else {

                                    Write-host "Execution Policy does not allow this script to run properly"
                                    Write-host "If you have the proper permissions,"
                                    Write-Host "Please close powershell,"
                                    Write-host "then right click the powershell icon and run as administrator"
                                    Write-host "Once in the powershell environment, execute the following:"
                                    Write-host "Set-ExecutionPolicy RemoteSigned -Force"

                                    }


                                    Enjoy.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Aug 8 '17 at 15:19

























                                    answered Aug 8 '17 at 15:11









                                    JaberwockyJaberwocky

                                    6961316




                                    6961316






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1365081%2fvirtualenv-in-powershell%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Costa Masnaga

                                        Fotorealismo

                                        Sidney Franklin