无法打开文件'django-admin.py':[Errno 2]没有这样的文件或目录 [英] Can't open file 'django-admin.py': [Errno 2] No such file or directory

查看:2017
本文介绍了无法打开文件'django-admin.py':[Errno 2]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python 2.7,Django 1.2.5和Windows 7。



我不知道我做了什么。我以前可以创建Django项目,如

  python django-admin.py startproject test 

现在我收到这个错误。


无法打开文件'django-admin.py':

[Errno 2]没有这样的文件或目录


我可以输入以下内容。

  python C:\Python27\Scripts\django-admin。 py startproject测试

我以前的方式怎么样?



我已经尝试过的东西:



我卸载了Python,并在Windows中手动删除了PATH变量中的值。重新安装Python。已删除Django并重新安装。



我已将 C:\Python27\Scripts 添加到我的 PATH



任何建议?



我的PATH变量包含

  C:\程序文件(x86)\NVIDIA Corporation\ PhysX\Common; C:\Program Files(x86)\ActiveState Komodo Edit 6\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32 \WindowsPowerShell\v1.0\; C:\django-apps; F:\My_Projects; C:\Program Files(x86)\QuickTime\QTSystem\; C:\Program Files\\ \\ TortoiseSVN\bin; C:\Program Files\Mercurial\bin; C:\Python27; C:\Python27\Scripts 

PYTHONPATH有

  C:\Python27; C:\Python27\\ \\Lib;ç :\Python27\DLLs; C:\Python27\Lib\lib-tk; C:\Python27\Scripts; C:\django-apps; f:\my_projects 


解决方案

我在Python 2.7.x和Django稍微更新的版本中也有同样的问题 - 而不是PATH。这就是我必须做的,在Windows XP中修复它:


  1. 查找.py文件(任何,甚至是空白)。

  2. 右键单击,然后选择打开方式,然后选择选择程序...。

  3. 这将弹出一个列表的所有程序 - 选择 python ,并选中始终使用所选程序打开此类文件框,然后单击确定。 / li>

选中此框将重置文件关联并修复命令行中的此问题。



问题的原因:告诉Windows在默认情况下在文本编辑器中打开.py文件。


I'm using Python 2.7, Django 1.2.5 and on Windows 7.

I am not sure what I've done. I used to be able to create Django projects like

python django-admin.py startproject test

Now however I get this error.

Can't open file 'django-admin.py':
[Errno 2] No such file or directory

I can type the following which works.

python C:\Python27\Scripts\django-admin.py startproject test

How can I have it the way it used to be? Not having the type the full path to the django-admin.py file.

Things I've already tried:

I uninstalled Python and manually removed the values from the PATH variable in Windows. Reinstalled Python. Deleted Django and reinstalled it too.

I've added C:\Python27\Scripts to my PATH and PYTHONPATH variable under Environmental Variables in Windows.

Any suggestions?

My PATH variable contains

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\ActiveState Komodo Edit 6\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\django-apps;F:\My_Projects;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Mercurial\bin;C:\Python27;C:\Python27\Scripts

PYTHONPATH has

C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts;C:\django-apps;f:\my_projects

解决方案

I had this same problem with slightly newer versions of Python 2.7.x and Django - and it is not the PATH. This is all I had to do to fix it in Windows XP:

  1. Find a .py file (any, even a blank).
  2. Right click on it and choose: "Open with>" and then select "Choose program...".
  3. This pops up a list of all programs - select python, and check the box "Always use the selected program to open this kind of file" and then click OK.

Checking this box resets file associations and fixes this problem for the command line.

The cause of the problem: Telling Windows to open up .py files in a text editor as default.

这篇关于无法打开文件'django-admin.py':[Errno 2]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆