virtualenv activate不起作用

时间:2017-05-26 05:45:29

标签: python powershell virtualenv

我正在尝试创建一个虚拟环境来测试api。

我可以使用virtualenv test创建环境,然后我可以进入它。当我尝试运行activate时,我收到此错误:

PS C:\Users\Bright Bridge\Desktop\autocomplete_demo\Scripts> activate
activate : The term 'activate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ activate
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (activate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command activate was not found, but does exist in the current location. Windows PowerShell does not load commands from the current
 location by default. If you trust this command, instead type: ".\activate". See "get-help about_Command_Precedence" for more details.

我最近更新了Windows,并用Windows Powershell替换了cmd。我的virtualenv与cmd工作得很好,所以我怀疑它可能与Powershell的工作方式有关。

如何激活virtualenv?

6 个答案:

答案 0 :(得分:3)

如果按WindowsKey + R,并在框出现时键入cmd,则应显示命令行界面而不是powershell!

答案 1 :(得分:1)

只需输入一个PowerShell命令

  1. 。\ Scripts \ activate

    然后

  2. ./脚本/激活

答案 2 :(得分:0)

答案 3 :(得分:0)

使用命令pompt代替使用power-shell 并运行相同的命令

enter image description here

这应该有效

答案 4 :(得分:0)

对于仍然感兴趣的人,输出将为您提供答案:

如果您信任此命令,请键入:“。\ activate”。

因此,请使用相对路径名在Powershell中运行激活脚本,或使用绝对路径

答案 5 :(得分:0)

你基本上需要为 PowerShell 设置执行策略

步骤 1:以管理员身份运行 PowerShell

第 2 步:在命令下方运行

Set-ExecutionPolicy RemoteSigned

成功运行后,您将能够激活垂直环境。

享受:)