首页 > 解决方案 > 无法在 Powershell 上激活 Virtualenv

问题描述

我正在尝试学习 Django。首先,我需要安装 Python、Django 和 Virtualenv。这些都安装没有错误。但是现在我想启动一个项目并运行 virtualenv,我无法在 powershell 中激活它。

我用这个命令制作了一个 virtualenv:

python -m virtualenv venv

现在教程说我必须像这样激活 virtualenv:

. \scripts\activate

但它给了我这个错误:

    . : The term '\scripts\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:3
+ . \scripts\activate
+   ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (\scripts\activate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我应该怎么办?

我已经尝试过scripts\activate.ps1,但它仍然无法正常工作。

标签: pythondjangovirtualenv

解决方案


您应该使用scripts\activate.ps1而不是scripts\activate. 在此处查找更多信息


推荐阅读