gpt4 book ai didi

python-sphinx - Sphinx 无法导入模块依赖项

转载 作者:行者123 更新时间:2023-12-04 17:32:50 33 4
gpt4 key购买 nike

写作的python工具,awscli-bastion , 具有以下由 cookiecutter 构建的目录结构.

.
├── awscli_bastion
│ ├── __init__.py
│ ├── cache.py
│ ├── cli.py
│ ├── credentials.py
│ ├── minimal.py
│ └── sts.py
├── docs
│ ├── Makefile
│ ├── _build
│ ├── ...
│ ├── conf.py
│ ├── ...
├── setup.py
├── .readthedocs.yml
│ ...

其中 setup.py 包含以下内容:

requirements = [ 'Click>=6.0', 'boto3>=1.5.0', 'awscli>=1.13.0', 'humanize>=0.5.1' ]

其中 conf.py 包含以下内容:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

import awscli_bastion

和 .readthedocs.yml 包含:
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7

在本地构建 sphinx 时,所有模块功能都会自动记录。

enter image description here

当我在 readthedoc.io 上构建时,它可以成功导入所有 awscli_bastion 包模块,但它无法自动记录模块功能,因为它在导入时失败。
WARNING: autodoc: failed to import module 'cache' from module 'awscli_bastion'; the following exception was raised:
No module named 'dateutil'
WARNING: autodoc: failed to import module 'cli' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'
WARNING: autodoc: failed to import module 'credentials' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'
WARNING: autodoc: failed to import module 'minimal' from module 'awscli_bastion'; the following exception was raised:
No module named 'boto3'
WARNING: autodoc: failed to import module 'sts' from module 'awscli_bastion'; the following exception was raised:
No module named 'botocore'

https://readthedocs.org/api/v2/build/9667746.txt

这是在 https://awscli-bastion.readthedocs.io/en/latest/awscli_bastion.html 上呈现的内容

enter image description here

为什么 readthedoc.io virtualenv 没有安装 setup.py 中定义的依赖项?

最佳答案

好的,我希望能够通过创建 docs/requirements.txt 来安装依赖项包含以下内容的文件:

Click>=6.0
boto3>=1.5.0
awscli>=1.13.0
humanize>=0.5.1
docutils>=0.15.2

然后在 .readthedocs.yml 中引用它
python:
version: 3.7
install:
- requirements: docs/requirements.txt

引用 setup.py 的要求会更理想,这样我就不必两次定义它们。

关于python-sphinx - Sphinx 无法导入模块依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57967426/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com