简体   繁体   English

Django-admin startproject永久修复程序?

[英]Django-admin startproject permanent fix?

I just installed Django yesterday and went through part 1 and 2 of the tutorial no problems. 我昨天刚安装了Django,并顺利完成了本教程的第1部分和第2部分。 Things were fuzzy so I wanted to start again. 事情很模糊,所以我想重新开始。 Between last night and now, only difference is I got Windows 10. 从昨晚到现在,唯一的区别是我安装了Windows 10。

I type into command: django-admin startproject mysite2 我输入命令:django-admin startproject mysite2

It shows no errors, but it does not pop mysite2 or anything into the directory I am in. After searching an hour or so, I find a solution in django-admin.py startproject is not working 它没有显示任何错误,但是不会将mysite2或任何内容弹出到我所在的目录中。搜索一个小时左右后,我在django-admin.py中找到了解决方案。startproject不起作用

If I type into cmd: python C:\\Python27\\Scripts\\django-admin.py startproject , it works. 如果我键入cmd:python C:\\ Python27 \\ Scripts \\ django-admin.py startproject,那么它将起作用。 However, it's going to get a bit tedious and I can't help but think this problem is going to extend further down the line too. 但是,这将变得有些乏味,我不禁认为这个问题也将进一步扩展。 What is the reason why I can only start the project this way, and is there a way I can permanently change it? 为什么我只能以这种方式启动项目,为什么可以永久更改它?

It sounds like when you upgraded, the PATH environment variable was modified. 听起来像是在升级时,PATH环境变量已被修改。 If that's the case, here's how you can fix it. 如果是这样,您可以通过以下方法进行修复。

Why can I only start the project this way? 为什么我只能以这种方式启动项目?

When the operating system sees the django-admin command, it does not know what that means. 当操作系统看到django-admin命令时,它不知道这意味着什么。 It checks the PATH variable (which holds a list of directories as a single string). 它检查PATH变量(将目录列表作为单个字符串保存)。 The OS will then check each of these directories for a program named django-admin . 然后,操作系统将在每个目录中检查名为django-admin的程序。 It appears that during the course of the upgrade the path variable was modified and now no longer includes C:\\Python27\\Scripts . 似乎在升级过程中,路径变量已修改,现在不再包含C:\\Python27\\Scripts

Is there a way to permanently change it? 有没有办法永久改变它?

Yes. 是。 You'll just need the add C:\\Python27\\Scripts to your PATH . 您只需要在PATH添加C:\\Python27\\Scripts This page explains how to update PATH for Windows 8 (though at the top it also says it is applicable to Windows 10). 本页说明了如何更新Windows 8的PATH (尽管在顶部还说它适用于Windows 10)。 Specifically: 特别:

Windows 8 Windows 8

1) Drag the Mouse pointer to the Right bottom corner of the screen 1)将鼠标指针拖到屏幕的右下角

2) Click on the Search icon and type: Control Panel 2)点击搜索图标并输入:控制面板

3) Click on -> Control Panel -> System -> Advanced 3)点击->控制面板->系统->高级

4) Click on Environment Variables, under System Variables, find PATH, and click on it. 4)单击环境变量,在系统变量下,找到PATH,然后单击它。

5) In the Edit windows, modify PATH by adding the location of the class to the value for PATH. 5)在“编辑”窗口中,通过将类的位置添加到PATH的值来修改PATH。 If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value. 如果没有PATH项,则可以选择添加一个新变量,并将PATH作为名称添加,将类的位置作为值添加。

6) Close the window. 6)关闭窗口。

我建议您重新安装python和django。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM