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

后端 未结 4 930
情话喂你
情话喂你 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
    
    0 讨论(0)
  • 2021-01-04 21:01

    Screenshot attached for reference. I've just encountered the same issue but I did the following:

    1. Create a new virtual environment;

      python -m venv directory

    2. Navigate into the newly created directory;

      cd directory

    3. Activate the virtual environment.

      .\Scripts\activate

    This resolved my problem. I hope it helps...

    0 讨论(0)
  • 2021-01-04 21:03

    I have also faced this issue. To solve this I created a new virtualenvironment as follows:

    python -m venv directory-name
    

    To activate:

    Scripts>./activate
    

    And Now it's working fine...

    0 讨论(0)
  • 2021-01-04 21:07

    I Also Faced the same issue solved it by using this :

    Created A Virtual Environment By : virtualenv environment

    After Creating Virtual Environment

    I activated it by using :

    source environment/bin/activate 
    

    And It activated my Virtual Environment

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