我正在嘗試設置一個自定義站點包目錄(Windows Vista上的Python 2.6)。例如,該目錄應該是'〜\ lib \ python2.6'(C:\ Users \ wierob \ lib \ python2.6)。因此,調用'setup.py install'應該將軟件包複製到C:\ Users \ wierob \ lib \ python2.6。如何使用Python 2.6的pth文件使用自定義站點包?
繼說明here:
我創建的Python安裝的site-packages目錄一個PTH文件(C:\ Python26 \ LIB \站點包)。此文件包含一行:
import os, site; site.addsitedir(os.path.expanduser('~/lib/python2.6'))
另外我有一個pydistutils.cfg我的家目錄(C:\用戶\ wierob),其中包含:
[install]
install_lib = ~/lib/python2.6
install_scripts = ~/bin
當我運行「的setup.py安裝'我收到以下錯誤消息:
C:\Users\wierob\Documents\Python\workspace\rsreader>setup.py install
running install
Checking .pth file support in C:\Users\wierob\lib\python2.6\
C:\Python26\pythonw.exe -E -c pass
TEST FAILED: C:\Users\wierob\lib\python2.6\ does NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
C:\Users\wierob\lib\python2.6\
因此,似乎pth文件不起作用。雖然,如果我在交互式python會話中輸入
site.addsitedir(os.path.expanduser('~/lib/python2.6'))
該目錄已成功添加到sys.path中。
任何想法?謝謝。
也直接將路徑添加到pth文件或將路徑添加到另一個包的現有pth文件不起作用。 – wierob 2009-07-21 16:34:11