python讀取類庫的順序是,當前目錄,pythonpath,path和安裝目錄。 可以動態的設置pythonpath如下:
- Python 2.6.3 : 75186 , Oct ( r263rc1 : 75186 , Oct 2 20 : 40 : 30 ) 2009 , 20 : 40 : 30 ) [ MSC v .1500 32 bit )] ( Intel )]
- on win32
- Type " , " copyright " , " credits " " help " , " copyright " , " credits " or " " license " for more information .
- >>> import sys
- . path >>> sys . path
- , ' C: \\ Python26 ' , ' C: \\ Windows \\ system32 \\ python26.zip ' , ' C: \\ Python26 \\ DLLs ' , [ '' , ' C: \\ Python26 ' , ' C: \\ Windows \\ system32 \\ python26.zip ' , ' C: \\ Python26 \\ DLLs ' ,
- \\ Python26 \\ lib ' , ' C: \\ Python26 \\ lib \\ plat-win ' , ' C: \\ Python26 \\ lib \\ lib-tk ' ' C: \\ Python26 \\ lib ' , ' C: \\ Python26 \\ lib \\ plat-win ' , ' C: \\ Python26 \\ lib \\ lib-tk '
- C: \\ Python26 \\ lib \\ site-packages ' ] , ' C: \\ Python26 \\ lib \\ site-packages ' ]
- . path . append ( ' c: \\ path ' ) >>> sys . path . append ( ' c: \\ path ' )
- . path >>> sys . path
- , ' C: \\ Python26 ' , ' C: \\ Windows \\ system32 \\ python26.zip ' , ' C: \\ Python26 \\ DLLs ' , [ '' , ' C: \\ Python26 ' , ' C: \\ Windows \\ system32 \\ python26.zip ' , ' C: \\ Python26 \\ DLLs ' ,
- \\ Python26 \\ lib ' , ' C: \\ Python26 \\ lib \\ plat-win ' , ' C: \\ Python26 \\ lib \\ lib-tk ' ' C: \\ Python26 \\ lib ' , ' C: \\ Python26 \\ lib \\ plat-win ' , ' C: \\ Python26 \\ lib \\ lib-tk '
- C: \\ Python26 \\ lib \\ site-packages ' , ' c: \\ path ' ] , ' C: \\ Python26 \\ lib \\ site-packages ' , ' c: \\ path ' ]
- >>>
還有就是修改環境變量。 增加一個PYTHONPATH
windows比較討厭的是有空格問題。
在系統變量裡面增加一個變量PYTHONPATH
值是:
- C:\\Program Files (x86)\\Google\\google_appengine;C:\\Program Files (x86)\\Google\\google_appengine\\lib\\antlr3;C:\\Program Files (x86)\\Google \\google_appengine\\lib\\django;C:\\Program Files (x86)\\Google\\google_appengine\\lib\\webob;C:\\Program Files (x86)\\Google\\google_appengine\\lib \\yaml\\lib;C:\\Program Files (x86)\\Google\\google_appengine;
只是gae執行起來還是有點問題,保存modle的時候,說沒有app id。 咳。
———–
python 2.6 開始,好像支持在site-packages目錄下建xxx.pth的文件,把要include的lib path寫進去即可。 這個方便,易於維護。 不錯更多可以看這個http://docs.python.org/library/site.html
Popularity: 4%






