如何让 Sphinx 在 PyCharm 和 Python 3.5 中工作

How to get Sphinx working in PyCharm with Python 3.5

这是我第一次在 PyCharm 5.0 和 Python 3.5 中使用 Sphinx。

当我在 运行 sphinx task 中 PyCharm 我得到以下错误:

File "C:\Program Files (x86)\JetBrains\PyCharm 5.0\helpers\docutils\__init__.py", line 63, in <module>
    class ApplicationError(StandardError): pass
NameError: name 'StandardError' is not defined

this page 我发现 Python 3.x StandardError 现在被 Exception 代替了。但是,当我尝试编辑 __init__.py 文件时,PyCharm 阻止我保存它。

我还注意到 __init__.py 基于 docutils 0.8 版。这并不直观,因为我在我的 virtualenv 中安装了 docutils 版本 0.12。这意味着版本 0.12 被忽略了。

有人知道如何解决这个问题吗?

更新:PyCharm 5.0.2 修复了这个问题,Sphinx 运行 配置在 Python 3

下工作

不幸的是 Python 代码在 PyCharm pre-5.0.2 helpers 中提供的代码与 Python 3 不兼容。 PyCharm 问题跟踪器有一张票。我曾经试过修复所有的小问题,但后来 运行 变成了一些更大的问题。

因此,只需进行 运行 配置调用:

  • Script (on Mac): /Users/paul/projects/jetbrains/env35/bin/sphinx-build
  • Script parameters: -b html -d _build/doctrees . _build/html

...并将工作目录设置为您想要 _build 目录的位置。


编辑: 在 pycharm 中添加了关于如何创建和编辑 run/debug 配置的 link 和 [=46= 的屏幕截图].脚本位置是 'Scripts' 而不是 'bin'.

Creating and Editing Run/Debug Configurations in PyCharm 5.0

PyCharm 5.0 截图(Windows)