(已解决)restructuredtext+sphinx 修改 html theme

使用sphinx自带的bizstyle theme没有问题,运行后生成html样式如下:

.

我想把bizstyle改成Sphinx Bootstrap Theme,链接在这里:
https://ryan-roemer.github.io/sphinx-bootstrap-theme/README.html

按它的安装说明,我运行:
pip install sphinx_bootstrap_theme

然后修改conf.py,在文件最上方添加:
import sphinx_bootstrap_theme
在文件中间theme处修改为:
html_theme = 'bootstrap'
并在下面添加一行:
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()

然后运行make html会报错,全部错误信息如下:

Running Sphinx v1.7.9

Configuration error:
There is a programable error in your configuration file:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 161, in __init__
    execfile_(filename, config)
  File "/usr/lib/python3/dist-packages/sphinx/util/pycompat.py", line 150, in execfile_
    exec_(code, _globals)
  File "conf.py", line 9, in <module>
    import sphinx_bootstrap_theme
ImportError: No module named 'sphinx_bootstrap_theme'

Makefile:20: recipe for target 'html' failed
make: *** [html] Error 2

有点搞不懂了,应该咋搞?

你的安装有问题。去找找你装哪儿了,为什么 Python 找不到。
另外你这是 Debian 吧?

对,debian~
你说的安装有问题,是指sphinx安装?

是指你 pip 安装的 sphinx_bootstrap_theme。
我移一下帖子。

我在这个目录里能找到sphinx_bootstrap_theme目录和sphinx_bootstrap_theme-0.7.1.dist-info目录:
.local/lib/python2.7/

那些sphinx自带的theme,在这里:
.local/lib/python2.7/site-packages/sphinx/themes/

我把phinx_bootstrap_theme目录拷贝到.local/lib/python2.7/site-packages/sphinx/themes/目录,结果还是不行~

你跑 sphinx 的 Python 不是 3 么?

果然,我用pip3 install sphinx_bootstrap_theme 再装了一次,之后make html已经不报错了,生成的html页面也是正确的~