问题描述
我正在使用 Python 2.7、Django 1.2.5 和 Windows 7.
I'm using Python 2.7, Django 1.2.5 and on Windows 7.
我不确定我做了什么.我曾经能够创建类似的 Django 项目
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.
无法打开文件django-admin.py":
[Errno 2] 没有这样的文件或目录
Can't open file 'django-admin.py':
[Errno 2] No such file or directory
我可以输入以下内容.
python C:Python27Scriptsdjango-admin.py startproject test
我怎样才能拥有它以前的样子?没有输入 django-admin.py 文件的完整路径.
How can I have it the way it used to be? Not having the type the full path to the django-admin.py file.
我已经尝试过的事情:
我卸载了 Python 并手动从 Windows 中的 PATH 变量中删除了这些值.重新安装了 Python.删除 Django 并重新安装.
I uninstalled Python and manually removed the values from the PATH variable in Windows. Reinstalled Python. Deleted Django and reinstalled it too.
我已将 C:Python27Scripts 添加到 PATH 和 环境变量 下的 PYTHONPATH 变量中在 Windows 中.
I've added C:Python27Scripts to my PATH and PYTHONPATH variable under Environmental Variables in Windows.
我的 PATH 变量包含
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 有
PYTHONPATH has
C:Python27;C:Python27Lib;C:Python27DLLs;C:Python27Liblib-tk;C:Python27Scripts;C:django-apps;f:my_projects
推荐答案
我在 Python 2.7.x 和 Django 的稍新版本中也遇到了同样的问题 - 这不是 PATH.这就是我在 Windows XP 中修复它所要做的全部工作:
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:
- 找到一个 .py 文件(任意,甚至是空白).
- 右键单击它并选择:打开方式>",然后选择选择程序...".
- 这会弹出所有程序的列表——选择
python
,并勾选始终使用选定的程序打开这种文件",然后点击OK.
- Find a .py file (any, even a blank).
- Right click on it and choose: "Open with>" and then select "Choose program...".
- 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.
问题的原因:告诉 Windows 默认在文本编辑器中打开 .py 文件.
The cause of the problem: Telling Windows to open up .py files in a text editor as default.
这篇关于无法打开文件 'django-admin.py':[Errno 2] 没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!