当使用zc.buildout遇到关于双重导入pkg_resources的“UserWarning”时

时间:2011-07-27 16:13:19

标签: python buildout

当我运行bin/buildout时,警告重复如下:

/Users/healdream/Playground/python/buildout/parts/buildout/site.py:262: UserWarning: Module pkg_resources was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py, but /Users/healdream/Playground/python/buildout/eggs/distribute-0.6.19-py2.6.egg is being added to sys.path
  import pkg_resources

我使用zope的bootstrap.py,在运行bin/buildout之前,我运行了python bootstrap.py --distribute

在bootstrap.py中,pkg_resources被导入,而bin / buildout parts/buildout被添加到sys.path

sys.path[0:0] = [
    '/Users/healdream/Playground/python/buildout/parts/buildout',
    ]

在parts / buildout / site.py:262中,再次显式导入pkg_resources import pkg_resources。所以出现警告。

如何避免警告?

1 个答案:

答案 0 :(得分:0)

这可能是一个隔离问题,只能通过升级解决,因为它取代了基本安装。如果它再次发生,尝试virtualenv是一个好主意:

$ virtualenv --no-site-packages .
$ bin/python bootstrap.py
$ bin/buildout