【问题标题】:I try to run my venv in python, however I ger errors, terminal says The term '.\venv\Scripts\activate' is not recognized as the name of a cmdlet我尝试在 python 中运行我的 venv,但是出现错误,终端说 The term '.\venv\Scripts\activate' is not known as the name of a cmdlet
【发布时间】:2022-01-21 05:30:40
【问题描述】:

我是 react js 开发者,我想运行我代码的后端部分,后端开发者说我要下载 python 并在 webstorm 终端中运行以下命令。

激活虚拟环境

python3 -m venv venv
.\venv\Scripts\activate
python .\manage.py runserver

当我尝试这样做时,我得到了无法修复的错误。下面的错误。

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

请帮我激活python服务器

【问题讨论】:

  • 只是发泄\脚本\激活;开始时不需要 .\ 我的意思是 .
  • 你在powershell中所以你需要使用Activate.ps1
  • 现在我收到无法加载模块“venv”的错误。有关更多信息,请运行“Import-Module venv”。
  • 我想我是在考虑 windows cmd 提示符。总的来说,它应该有点不同。

标签: python reactjs virtualenv


【解决方案1】:

由于您使用的是 PowerShell,请使用以下命令:

.\venv\Scripts\Activate.ps1

确保大小写正确。

【讨论】:

  • 兄弟,你能告诉我应该在 webstorm 终端中运行的命令吗?
  • 我做到了。提示应该是PS C:\Users\User\Desktop\OK_COMPANY。将.\venv\Scripts\Activate.ps1 复制并粘贴到提示符中,然后按 Enter。接下来,输入python .\manage.py runserver 并按Enter,您应该已经准备好了。
猜你喜欢
  • 1970-01-01
  • 2022-10-21
  • 2023-02-09
  • 1970-01-01
  • 1970-01-01
  • 2020-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多