virtualenv in PowerShell?

后端 未结 13 2046
悲&欢浪女
悲&欢浪女 2020-12-12 20:32

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

相关标签:
13条回答
  • 2020-12-12 21:23

    try this: . .\env\Scripts\activate.ps1 watch dots and spaces

    0 讨论(0)
  • 2020-12-12 21:24

    Just run first

    Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
    

    and then

    ./env/Scripts/activate.sp1
    

    That's all

    0 讨论(0)
  • 2020-12-12 21:26

    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/

    0 讨论(0)
  • 2020-12-12 21:28

    On Windows PowerShell, I have to type from the venv/Scripts folder :

    . ./activate
    
    0 讨论(0)
  • 2020-12-12 21:29

    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.

    0 讨论(0)
  • 2020-12-12 21:31

    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:

    . .\env\Scripts\activate.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: . .\env\Scripts\activate.ps1

    0 讨论(0)
提交回复
热议问题