Skip to main content
 首页 » 编程设计

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

2024年11月01日7qlqwjy

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

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