Python 在 Windows 7 上将“django-admin.py”路径添加到命令行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17836416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 09:17:11  来源:igfitidea点击:

Add "django-admin.py" path to command line on Windows 7

pythondjangowindowswindows-7cmd

提问by Michael

I've been trying to add the django-admin.pypath to command line on Windows 7.

我一直在尝试django-admin.py在 Windows 7 上添加到命令行的路径。

I have tried to do it this way:

我试图这样做:

C:\>set django-admin.py = C:\Python27\Scripts\django-admin.py

But cmdtold me that:

但是cmd告诉我:

'django-admin.py' is not recognized as an internal or external command.

So how can I add django-admin.pypath to command line on Windows 7?

那么如何django-admin.py在 Windows 7 上向命令行添加路径?

I need it because later I'm doing this:

我需要它,因为稍后我会这样做:

  C:\Users\Michael\Desktop\mysite>django-admin.py startproject mysite

Thanks.

谢谢。

采纳答案by falsetru

Try following command.

尝试以下命令。

set path=%path%;c:\python27\scripts

PATHis set only for the cmd.exe in which you run the above command.

PATH仅为运行上述命令的 cmd.exe 设置。

UPDATE

更新

To permanently set PATH:

永久设置路径:

  1. Right click My computerin the desktop.
  2. Click Advanced System Settingson the left.
  3. Click Environmental Variable.
  4. Add or Update PATHvariable:
    • If it does not exist, create one, and set value as C:\python27\scripts
    • If it exist, append ;C:\Python27\scriptsto existing value.
  5. Restart cmd.exe. (PATH will not change for already launched cmd.exe)
  1. 右键单击桌面上的我的电脑
  2. 单击左侧的高级系统设置
  3. 单击环境变量
  4. 添加或更新PATH变量:
    • 如果不存在,则创建一个,并将值设置为 C:\python27\scripts
    • 如果存在,则附加;C:\Python27\scripts到现有值。
  5. 重启cmd.exe。(对于已经启动的 cmd.exe,PATH 不会改变)