python - 尝试在某些 GIMP Python 插件代码上运行 Sphinx 时出错

标签 python python-3.x python-sphinx gimp gimpfu

我正在尝试使用 Sphinx 来记录一个 Python 文件,该文件用于实现 GIMP 插件。问题是,当我运行时;

make html

我收到以下消息 - 如下所示,产生错误;

sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v2.2.0
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] code                                                                                                                        
WARNING: autodoc: failed to import module 'Plugin_ImageOverlay'; the following exception was raised:
Traceback (most recent call last):
  File "/home/craig/.local/lib/python3.5/site-packages/sphinx/ext/autodoc/importer.py", line 32, in import_module
    return importlib.import_module(modname)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/craig/.gimp-2.8/plug-ins/ImageOverlay/Plugin_ImageOverlay.py", line 73, in 
  <module>
    from   gimpfu import register, main, pdb, gimp, PF_IMAGE, PF_DRAWABLE, PF_INT, 
    PF_STRING, PF_FILE, PF_BOOL, INTERPOLATION_NONE, INTERPOLATION_LINEAR, 
    INTERPOLATION_CUBIC, INTERPOLATION_LANCZOS, PF_RADIO
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 235
    raise error, "parameter name contains illegal characters"
               ^
SyntaxError: invalid syntax

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                                                                        
generating indices...  genindexdone
writing additional pages...  search/home/craig/.local/lib/python3.5/site-
packages/sphinx_rtd_theme/search.html:20: RemovedInSphinx30Warning: To modify script_files 
in the theme is deprecated. Please insert a <script> tag directly in your theme instead.
{{ super() }}
done
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in _build/html.

Build finished. The HTML pages are in _build/html.

如果从上面的输出中看不出来,错误消息会显示;

  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 235
    raise error, "parameter name contains tllegal characters"
               ^
SyntaxError: invalid syntax

我不太了解 Python 或 Sphinx,但是这个错误是否与 Python 版本 2 和 3 之间的语法差异有关?我的插件可以通过 GIMP 毫无问题地加载和执行 - 那么为什么 Sphinx 似乎对它感到窒息呢?

是否有一些我不知道的简单解决方法,例如可以放置在 Sphinx 的 conf.py 文件中的键值对?

预先感谢您的帮助。

最佳答案

您使用的是 Sphinx 2.2.0 版本,Sphinx dropped support for Python 2 since 2.0.x

gimpfu.py 中的引发错误,e 样式为not supported in Python 3.x 。 (您应该使用引发错误(e))

您可以尝试使用支持 Python 2 的旧版 Sphinx,或者破解 gimp 以使用 Python 3 兼容语法,或者要求 gimp 人员修复它...

关于python - 尝试在某些 GIMP Python 插件代码上运行 Sphinx 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58080739/

相关文章:

templates - 找不到 Sphinx 内置主题

python - 如何让 Sphinx 忽略我的文档字符串中的 GPL 通知?

python - 排序字符串列表时的问题

python - 在 NLTK 中找不到 ghostscript?

python - 当 Pepper 未连接到同一网络时,通过 Choregraphe/python 脚本连接到 Pepper

python - JupyterLab : Run all cells below

django - 为什么在 Django 中使用信号?

python - pygame 屏幕仅在我将窗口移出屏幕时才起作用

python - 让 Sphinx 检测对辅助配置/模板文件的更改

python - 使用 pywin32 的带有子菜单的 Windows 资源管理器上下文菜单