virtualenv v16.7.2 powershell activate script: “You must 'source' this script: PS> . .\ENV\Scripts\activate” error

后端 未结 4 954
情话喂你
情话喂你 2021-01-04 20:44

The Problem

Newest version of virtualenv (16.7.2) on python v.3.7.4 has 4 additional lines for the "activate.ps1" script, which when run on Windows10 powe

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-04 20:52

    Let's have a look at that error message:

    You must 'source' this script: PS> . .\ENV\Scripts\activate

    Hmmmm... - PS> is probably just the prompt, which leaves us with this:

      . .\ENV\Scripts\activate
    # ^
    # |
    # Check out this guy
    

    That, the lonely . in front of the path, that is the dot-source operator in powershell.

    According to the documentation, it:

    Runs a script in the current scope so that any functions, aliases, and variables that the script creates are added to the current scope.

    I haven't had a look at virtualenv, but I assume it'll want to define a number of variables and to ensure that these persist after the script has run, it needs to be run in the current scope.

    So this is the literal command you have to run to fix it:

    . .\ENV\Scripts\activate
    

提交回复
热议问题