python Django的路径 [英] python path django
问题描述
如何向"Pythonpath"中添加内容.
How can I add something to my "Pythonpath".
文件确切位于哪里,我必须更改以添加到我的pythonpath中?
Where exactly are the files located, I have to change to add to my pythonpath?
我到底要添加什么到我的Python路径中?
What exactly do I add to my Pythonpath?
如果Python调用:
If Python calls:
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/
但是我要它打电话
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
我需要添加什么才能使其正常工作.
What do I need to add to make it work.
奇怪的是,我已经将django-admin.py用于startproject ccommand.但是现在找不到了.
Strange is that I already used the django-admin.py for a startproject ccommand. But now it does not find it.
有没有办法清理我所有的Python(Django),以便我可以使用新版本重新启动?
Is there a way to clean up my ALL my Python, Django so I can restart with a fresh version?
推荐答案
>>> import sys
>>> sys.path
sys.path
是模块的搜索路径列表.
sys.path
is the list of search path for modules.
如果要从/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
而不是/Library/Frameworks加载模块/Python.framework/Versions/2.6/Resources/Python.app/Contents/
您只需要确保 site-packages
搜索路径位于sys.path中的 Contents
之前
you just need to make sure that site-packages
search path comes before the Contents
in sys.path
您可以使用 PYTHONPATH
环境变量设置python路径
you can set the python path using PYTHONPATH
environment variable
ex :(在Linux系统上)
ex: (on a linux system)
export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages:$PYTHONPATH
这篇关于python Django的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!