如何让Python知道寻找.py文件的路径?
今天刚开始尝试学习Python和Django。按照他们的文档,我能够安装 Python 和 Django 并让它们启动并运行。顺便说一句,我在 Windows 7 上运行 Apache 2.2。
我到达了官方教程中的部分,告诉我 cd 到我想要的项目目录并运行此命令
django-admin.py startproject mysite
但是我不能只运行该命令是。我需要像这样运行它
python c:\Python27\Scripts\django-admin.py startproject mysite
我应该像这样输入整个内容吗?或者是否有一些我错过的设置可以让我运行 .py 文件而不需要前面的 python C:\Python27\Scripts\ 部分?
Just started trying to learn Python and Django today. Following their documentations I was able to install Python and Django and got them up and running. I'm running Apache 2.2 on on Windows 7 by the way.
I got to the part in the official tutorial that tells me to cd to the directory I want for my project and run this command
django-admin.py startproject mysite
However I can't just run that command as is. I need to run it like this
python c:\Python27\Scripts\django-admin.py startproject mysite
Am I suppose to type out the whole thing like this? Or is there some settings I miss that will let me run the .py file without the python C:\Python27\Scripts\
part in front?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想输入 django-admin.py,则需要设置两件事:
如何在 Windows 7 上设置 PATH:http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
如何确保 .py 与 Python 关联: http://docs.python.org/faq/windows .html
If you want to just be able to type
django-admin.py
, two things need to be set up:How to set the PATH on Windows 7: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
How to make sure .py is associated with Python: http://docs.python.org/faq/windows.html
尝试运行:
如果这不起作用,请尝试将
C:\Python27\
添加到命令搜索路径Try running:
If that don't work, try adding
C:\Python27\
to the command search path