virtualenv won't activate on windows

后端 未结 18 1626
走了就别回头了
走了就别回头了 2020-12-07 14:05

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

I\'m doing this inside of windows powershell through using

scripts\\a         


        
相关标签:
18条回答
  • 2020-12-07 14:31

    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! https://www.youtube.com/watch?v=Q2uLUuq0Ft4

    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 !

    example

    0 讨论(0)
  • 2020-12-07 14:33

    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 Scripts\activate to activate your env

    0 讨论(0)
  • 2020-12-07 14:33

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

    0 讨论(0)
  • 2020-12-07 14:34

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

    enter image description here

    0 讨论(0)
  • 2020-12-07 14:37

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

    To deactivate the environment

    1. .\env\Scripts\deactivate

    Hope it helps.

    For more help do visit the official page https://pypi.org/project/virtualenv/1.8.2/

    0 讨论(0)
  • 2020-12-07 14:38

    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.

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