rst2html.py打印“文件对象析构函数中的关闭失败”

2 投票
2 回答
720 浏览
提问于 2025-04-17 23:24

我写了这个命令来检查setup.py文件中的长描述。

python setup.py --long-description | rst2html.py > output.html

但是它打印出了这个信息。

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

我打开了output.html,但output.html是空白的。

我的环境是Windows上的Python 2.7.5。

请给点建议。

setup.py

from distutils.core import setup

setup(
    name = "test", 
    version = "0.1",
    author = "test",
    author_email = "test@test.com",
    url = "test.com"
    packages = ["test"],
    license = "MIT License",
    description = "test",
    long_description = """
    ====
    test
    ====
    """,
    classifiers = [
        "Programming Language :: Python"
        ]
)

2 个回答

0

你的 setup.py 文件里缺少一个逗号:

    url = "test.com"
    packages = ["test"],

应该是这样的:

    url = "test.com",
    packages = ["test"],

另外,你的描述有缩进,这样会导致 rst 出错。你可以使用 textwrap.dedent,或者干脆不缩进,像这样:

from distutils.core import setup

long_description = """
test
====

fooo
"""

setup(
    name="test",
    version="0.1",
    author="test",
    author_email="test@test.com",
    url="test.com",
    packages=["test"],
    license="MIT License",
    description="test",
    long_description=long_description,
    classifiers=[
        "Programming Language :: Python"
    ]
)
0

这个问题是通过以下方式解决的:

<Path to setup.py> pip install docutils

看起来没有错误。

但是输出的 output.html 还是一片空白。

撰写回答