如何使用Python2.6的pthfiles自定义sitepackage?

2024-10-01 15:32:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试设置一个自定义站点包目录(WindowsVista上的Python2.6)。例如,目录应该是“~\lib\python2.6”(C:\Users\wierob\lib\python2.6)。所以我叫他设置.pyinstall'应该将包复制到C:\Users\wierob\lib\python2.6。在

按照说明here

我在Python安装的site packages目录中创建了一个pth文件(C:\Python26\Lib\site packages)。此文件包含一行:

import os, site; site.addsitedir(os.path.expanduser('~/lib/python2.6'))

另外我还有一个pydistutils.cfg我的主目录(C:\Users\wierob),其中包含:

^{pr2}$

当我跑的时候设置.pyinstall'我收到以下错误消息:

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会话中,目录被成功地添加到搜索路径. 在

有什么想法吗?谢谢。在


Tags: install文件path目录oslibpackagessite

热门问题