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
First, set the path in PowerShell (in your $profile) like this:
Then, to get .py files to open in PowerShell rather than cmd, add this line:
Finally, to be able to just type "django-admin" and have it work, add this line:
That should do the trick.
The problem seems to be with the file association. After adding the PATH variables, remove all "py" associations instead of linking them to your Python executable:
Remove the file type ".py " from the registry or by using a small free tool for Windows Vista/Windows 7 called 'Unassoc' (google for Windows 7 unassoc).
In my case simply unassociating the file type was not enough. I had to remove the file type entirely using the unassoc tool.
Now you should be good to go.
On Windows, I used
and it seemed to have worked.
Make sure that you cd is where you saved your Notepad++ Python file. If you saved it under your \Python27\ directory, then while in the terminal or PowerShell window, type
cd C:\Python27
and press enter.This will open that directory so when you type
python filename.py
it will find it and run it. Just remember to save all .py files to the same directory, so you have no further problems.Is it possible you associated your .py files with another program (like a text editor)? I had this problem, too, after associating .py files with gedit.
I'd have the problem if I did this:
Once I reassociated .py files to python this problem went away.
Here is what I did to get this working:
This is what I did beyond the install instructions that made it work for me on Windows:
PYTHONPATH
=c:\Python27\Lib;c:\Python27\Scripts
PATH
added:C:\Python27;C:\Python27\Scripts to the end.
The result:
Please post any questions in the comments, maybe I can help.