【问题标题】:Sphinx documentation locally works, but not on read the docsSphinx 文档在本地有效,但在阅读文档时无效
【发布时间】:2014-03-31 12:25:02
【问题描述】:

我开始为我的 lil' python/django 项目编写文档。

发生这种情况:

Running Sphinx v1.2
loading translations [en]... done
building [readthedocs]: targets for 18 source files that are out of date
updating environment: 18 added, 0 changed, 0 removed
reading sources... [  5%] administrator-guide/customizing
reading sources... [ 11%] administrator-guide/index
reading sources... [ 16%] developer-guide/index
reading sources... [ 22%] index
reading sources... [ 27%] modules/booking
Sphinx Standard Error
Sphinx error:
'ascii' codec can't decode byte 0xef in position 475: ordinal not in range(128)

我明白,这是一个编码问题。

但是:我所有的文件都是用 UTF-8 编码的。并且它可以在本地(Windows)工作。

这是我的modules/booking.rst。还有in this directory are my booking-module-files

非常感谢任何帮助!

【问题讨论】:

    标签: python python-sphinx


    【解决方案1】:

    PEP 0263 所述,将其添加到源文件的顶部可确保它与 utf-8 编码一起正常工作。

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    

    当我在源文件的字符串文字中有一些日文字符时,我个人遇到了这个问题。

    【讨论】:

    • 好吧,这太疯狂了。我将 encoding=utf-8 添加到所有文件中,现在它可以工作了。即使在这些文件中也没有字符 utf8-only。尽管如此。谢谢!
    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 2010-11-10
    • 1970-01-01
    相关资源
    最近更新 更多