如何使Python知道寻找.py文件的路径? [英] How to make Python knows the path to look for .py files?
问题描述
刚刚开始尝试学习Python和Django。在他们的文档之后,我能够安装Python和Django并让它们运行。我在Windows 7上运行Apache 2.2。
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.
我到官方教程的那一部分,告诉我cd到我想要的目录项目并运行此命令
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
我想输入整个类似的东西吗?或者有一些设置,我想,让我运行.py文件没有 python C:\Python27 \Scripts \
部分在前面?
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?
推荐答案
如果你只想输入 django-admin.py
需要设置的事情:
If you want to just be able to type django-admin.py
, two things need to be set up:
- 包含它的目录需要在您的PATH中。
- 您需要确保.py扩展名与Python解释器相关联。
如何在Windows 7上设置PATH: http://geekswithblogs.net/renso /archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
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
如何制作确定.py与Python相关联: http://docs.python.org/faq/windows.html
How to make sure .py is associated with Python: http://docs.python.org/faq/windows.html
这篇关于如何使Python知道寻找.py文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!