Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用Sphinx可读性主题_Python_Themes_Python Sphinx - Fatal编程技术网

Python 无法使用Sphinx可读性主题

Python 无法使用Sphinx可读性主题,python,themes,python-sphinx,Python,Themes,Python Sphinx,我想为我的狮身人面像使用可读性主题,这是可用的。但是,当我试图按照说明中的建议修改我的conf.py文件来使用此主题时,在执行make html时显示此错误: sphinx构建-b html-d构建/doctrees源构建/html 运行Sphinx v1.3.1 正在加载酸洗环境。。。完成 主题错误: 未找到名为“可读性”的主题(缺少theme.conf?) make:**[html]错误1 我看到人们以前在报道的其他一些主题上也遇到过类似的问题。但是,在我的例子中,conf.py文件就在那

我想为我的狮身人面像使用可读性主题,这是可用的。但是,当我试图按照说明中的建议修改我的
conf.py
文件来使用此主题时,在执行
make html
时显示此错误:

sphinx构建-b html-d构建/doctrees源构建/html
运行Sphinx v1.3.1
正在加载酸洗环境。。。完成
主题错误:
未找到名为“可读性”的主题(缺少theme.conf?)
make:**[html]错误1
我看到人们以前在报道的其他一些主题上也遇到过类似的问题。但是,在我的例子中,
conf.py
文件就在那里

更新 我在一个
virtualenv
中尝试了这个主题,使用了一个更新的
sphinx
。在执行
生成html
时显示此错误:

sphinx构建-b html-d构建/doctrees源构建/html
运行Sphinx v1.3.1
正在加载酸洗环境。。。完成
生成[mo]:0个过期采购订单文件的目标
building[html]:1个过期源文件的目标
更新环境:添加0,更改0,删除0
正在查找现在过时的文件。。。找不到
正在准备文档。。。完成
正在写入输出。。。[100%]指数
正在生成索引。。。genindex
发生异常:
文件“~/DEVEL/python/sphinx/sphinx2/local/lib/python2.7/site packages/sphinx/jinja2glue.py”,第159行,在get_source中
提升模板未找到(模板)
TemplateNotFound:可读性/layout.html
如果要向开发人员报告问题,则完整的回溯已保存在/tmp/sphinx-err-q42_PH.log中。
如果是用户错误,也请报告,以便下次提供更好的错误消息。
错误报告可在以下位置的跟踪器中存档:。谢谢
make:**[html]错误1

因此,我可以通过将。在这个问题上也有一个共同点

配置:

我的
source/conf.py
如下所示:

import sphinxtheme

html_theme = 'readability'
html_theme_path = sphinxtheme.get_html_theme_path()
补丁:

这是我必须应用于
sphinxtheme/\uuuu init\uuuu.py
的补丁:

diff --git a/sphinxtheme/__init__.py b/sphinxtheme/__init__.py
index b0d6433..a3edbe0 100644
--- a/sphinxtheme/__init__.py
+++ b/sphinxtheme/__init__.py
@@ -1 +1,7 @@
-__import__('pkg_resources').declare_namespace(__name__)
\ No newline at end of file
+import os
+
+
+def get_html_theme_path():
+    """Return list of HTML theme paths."""
+    cur_dir = os.path.abspath(os.path.dirname(__file__))
+    return [cur_dir]
readability_path:  /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
relative_path:  ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme

我还提交了一份报告来解决这个问题

您可以通过执行以下操作来测试这一点:

mkvirtualenv test-sphinxtheme-readability
git clone https://github.com/prologic/test-sphinxtheme-readability.git
cd test-sphinxtheme-readability
pip install -r requirements.txt
make clean html
circuits.web build/html
访问:


解释:您遇到此问题的原因,以及我认为主题及其示例配置有点不正确的地方,是因为路径非常错误。见:

$ make clean html
rm -rf build/*
sphinx-build -b html -d build/doctrees   source build/html
Running Sphinx v1.3.1
making output directory...
readability_path:  /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
relative_path:  ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                         
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                                          
generating indices... genindex
Exception occurred:
  File "/home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinx/jinja2glue.py", line 159, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: readability/layout.html
The full traceback has been saved in /tmp/sphinx-err-8zoG8h.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:55: recipe for target 'html' failed
make: *** [html] Error 1

$ ls -lah /home/prologic/.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
total 32K
drwxr-xr-x  3 prologic users 4.0K Jun 15 09:30 .
drwxr-xr-x 37 prologic users 4.0K Jun 15 09:30 ..
-rw-r--r--  1 prologic users   55 Jun 15 09:30 __init__.py
-rw-r--r--  1 prologic users  243 Jun 15 09:30 __init__.pyc
drwxr-xr-x  3 prologic users 4.0K Jun 15 09:30 readability
-rw-r--r--  1 prologic users 5.6K Jun 15 09:30 readability_theme_support.py
-rw-r--r--  1 prologic users 2.8K Jun 15 09:30 readability_theme_support.pyc

$ ls -lah ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme
ls: cannot access ../../../.virtualenvs/sphinx-readability/lib/python2.7/site-packages/sphinxtheme: No such file or directory

感谢@JamesMills的努力。这完美地解决了问题。我会在几个小时内给你赏金。然而,你能详细说明出了什么问题吗。我们到底应该给狮身人面像主题什么位置?这个问题在其他一些主题中也会反复出现。我会尝试:)但我认为我发现一些主题的打包和/或实现很差@Jaememills也谢谢你的解释:)