[英]Why does sphinx conf.py gives me an error for trying to import sys
我正在尝试使用 sphinx 和 autodoc 创建一个简单的文档,但是 autodoc 无法改进我的模块。 图那是因为我没有将模块的路径添加到 conf.py 中的 sys 路径中
所以我在 conf.py 的开头添加了这个:
import sys
import os
sys.path.insert(0, os.path.abspath('.'))
现在我在使用 import sys 时遇到以下错误,我不知道为什么,因为我的代码与 sphinxs 示例中的代码相同。
Configuration error:
There is a syntax error in your configuration file: bad input (conf.py, line 20)
Did you change the syntax from 2.x to 3.x?
第 20 行是带有 import sys 的行,之前它只是自动生成的注释
自动生成的注释代码在代码和注释符号之间有一个空格,我没有注意到。
在 conf.py 中,在导入语句之前删除空格后,它按预期工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.