使用 nbsphinx 阅读文档

问题描述

我为 Read the Docs 创建了自己的 docs。查看我的存储库 我的一些文档文件是 jupyter notebook,所以我使用了 nbshpinx

在我的计算机中,我安装了所有依赖项,当我使用 make html效果很好。 但是,阅读文档会引发错误

Running Sphinx v1.8.5
loading translations [en]... done

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/complex-valued-neural-networks/envs/latest/lib/python3.7/site-packages/sphinx/registry.py",line 472,in load_extension
    mod = __import__(extname,None,['setup'])
ModuleNotFoundError: No module named 'nbsphinx'

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/complex-valued-neural-networks/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py",line 303,in build_main
    args.tags,args.verbosity,args.jobs,args.keep_going)
  File "/home/docs/checkouts/readthedocs.org/user_builds/complex-valued-neural-networks/envs/latest/lib/python3.7/site-packages/sphinx/application.py",line 228,in __init__
    self.setup_extension(extension)
  File "/home/docs/checkouts/readthedocs.org/user_builds/complex-valued-neural-networks/envs/latest/lib/python3.7/site-packages/sphinx/application.py",line 449,in setup_extension
    self.registry.load_extension(self,extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/complex-valued-neural-networks/envs/latest/lib/python3.7/site-packages/sphinx/registry.py",line 475,in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname,err)
sphinx.errors.ExtensionError: Could not import extension nbsphinx (exception: No module named 'nbsphinx')

Extension error:
Could not import extension nbsphinx (exception: No module named 'nbsphinx')

this tutorial 之后,我创建了两个 yml 文件并且错误更改为:

Error
Problem in your project's configuration. Invalid "conda.environment": environment not found

解决方法

解决了! 我关注了this tutorial

我在 readthedocs.yml 中添加:

python:
  version: 3
  install:
    - requirements: docs/requirements.txt
  system_packages: true

然后在 docs/requirements.txt 中:

ipykernel
nbsphinx

如果有问题,您可以随时查看repository我在哪里做的。