python - Sphinx 文档在本地有效,但无法阅读文档

标签 python python-sphinx

我开始为我的 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 .

非常感谢任何帮助!

最佳答案

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

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

当我在源文件的字符串文字中包含一些日语字符时,我个人遇到了这个障碍。

关于python - Sphinx 文档在本地有效,但无法阅读文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22761486/

相关文章:

Python:没有这样的测试方法:如何通过从另一个方法显式调用它来执行测试方法?

Python pickle 在版本之间转换为 unicode

python - Python 中的 C _IOR 函数等效于什么?

python-2.7 - Sphinx的LaTeX错误: file `titlesec.sty' not found

python - 在 Sphinx 文档中添加版权信息

python - 构建sphinx文档时导入模块失败

Python3 - 尝试获取数据属性值时,XPath 查询不会从站点返回整个列表

python - 如何使用 Sphinx 只构建一个文件

python - 如何让 Sphinx 忽略我的文档字符串中的 GPL 通知?

python - 我收到类型错误 : int object not callable