简体   繁体   English

django-admin.py startproject mysite无法正常工作python 2.7

[英]django-admin.py startproject mysite not working python 2.7

I've read a ton of articles about adding things to the windows PATH variable but none of them have worked so far. 我读了很多关于将内容添加到Windows PATH变量的文章,但是到目前为止,它们都没有起作用。 I also read about editing regedit and finding some things, however I was unable to find what people were referring to. 我还阅读了有关编辑regedit和查找某些内容的信息,但是我找不到人们指的是什么。

So I'm trying to run: 所以我正在尝试运行:

django-admin.py startproject mysite

Previously it would open a window asking me which program to open the file with. 以前,它将打开一个窗口,询问我使用哪个程序打开文件。 I stupidly added it to python.exe, however I think this is now causing more problems as when I run the above command it opens a little black windows then vanishes as Python.exe now tries to open the file. 我愚蠢地将其添加到python.exe中,但是我认为这现在引起了更多问题,因为当我运行上述命令时,它会打开一个黑色的小窗口,然后消失,因为Python.exe现在尝试打开该文件。 But I think this could be preventing the command working? 但是我认为这可能会阻止命令正常工作?

It certainly isn't creating anything... 它肯定没有创造任何东西...

Would this indeed cause problems, or are things just as broke as previously? 这确实会引起问题,还是事情像以前一样破裂? Really need some help here, it's very frustrating that nothing seems to get it working. 这里确实需要一些帮助,非常令人沮丧的是似乎没有任何方法可以使它正常工作。 Is there is additional information you need, please let me know. 是否有您需要的其他信息,请告诉我。

I think your system is not finding the file django-admin.py. 我认为您的系统找不到文件django-admin.py。 Use cmd and navigate to the directory that contains this file and try to execute the command from there: 使用cmd并导航到包含此文件的目录,然后尝试从此处执行命令:

python django-admin.py startproject mysite

If it works, I recommend you to create an environment variable (eg DJANGO_ADMIN) to point do django-admin.py so you can execute the command below from anywhere: 如果可行,建议您创建一个环境变量(例如DJANGO_ADMIN)以指向do django-admin.py,以便您可以在任何地方执行以下命令:

python %DJANGO_ADMIN% startproject mysite 

EDIT: 编辑:

Creating an environment variable on Windows XP : Windows XP上创建环境变量:

  1. Open System in Control Panel. 在控制面板中打开系统。

  2. On the Advanced tab, click Environment Variables, then click the name of the user variable or system variable you want to change, as follows. 在“高级”选项卡上,单击“环境变量”,然后单击要更改的用户变量或系统变量的名称,如下所示。 Click 'New' to add a new variable name and value. 单击“新建”以添加新的变量名称和值。

Creating an environment variable on Windows 7 : Windows 7上创建环境变量:

  1. Open the Start Menu and right click on Computer. 打开“开始”菜单,然后右键单击“计算机”。 Select Properties. 选择属性。
  2. Select Advanced system settings. 选择高级系统设置。
  3. In the Advanced tab, select Environment Variables. 在“高级”选项卡中,选择“环境变量”。
  4. Select 'New'. 选择“新建”。

Creating an environment variable on Windows 8 : Windows 8上创建环境变量:

Start -> All Apps -> Control panel -> System -> Advanced System Settings -> Advanced -> Environment variables. 开始->所有应用->控制面板->系统->高级系统设置->高级->环境变量。

You can Follow @AmauryMedeiros answer or you can set a path to system environment variable to C:\\Python27\\Scripts . 您可以关注@AmauryMedeiros答案,也可以将系统环境变量的路径设置为C:\\Python27\\Scripts

It works... 有用...

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

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