Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
681 views
in Technique[技术] by (71.8m points)

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

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:Python27Scriptsdjango-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:Python27Scripts to my PATH and PYTHONPATH variable under Environmental Variables in Windows.

Any suggestions?

My PATH variable contains

C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)ActiveState Komodo Edit 6;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerShellv1.0;C:django-apps;F:My_Projects;C:Program Files (x86)QuickTimeQTSystem;C:Program FilesTortoiseSVNin;C:Program FilesMercurialin;C:Python27;C:Python27Scripts

PYTHONPATH has

C:Python27;C:Python27Lib;C:Python27DLLs;C:Python27Liblib-tk;C:Python27Scripts;C:django-apps;f:my_projects
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...