【发布时间】:2009-07-21 14:45:37
【问题描述】:
我正在尝试设置自定义站点包目录(Windows Vista 上的 Python 2.6)。例如,目录应该是 '~\lib\python2.6' (C:\Users\wierob\lib\python2.6)。因此调用 'setup.py install' 应该将包复制到 C:\Users\wierob\lib\python2.6。
按照说明here:
我在 Python 安装的 site-packages 目录 (C:\Python26\Lib\site-packages) 中创建了一个 pth 文件。此文件包含一行:
import os, site; site.addsitedir(os.path.expanduser('~/lib/python2.6'))
此外,我的主目录 (C:\Users\wierob) 有一个 pydistutils.cfg,其中包含:
[install]
install_lib = ~/lib/python2.6
install_scripts = ~/bin
当我运行“setup.py install”时,我收到以下错误消息:
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 文件不起作用。虽然,如果我输入
site.addsitedir(os.path.expanduser('~/lib/python2.6'))
在交互式 python 会话中,目录已成功添加到 sys.path。
有什么想法吗?谢谢。
【问题讨论】:
-
同样将路径直接添加到 pth 文件或将路径添加到另一个包的现有 pth 文件不起作用。
标签: python