Relative imports require the 'package' argument

前端 未结 5 1599
太阳男子
太阳男子 2021-02-07 01:44

I want to use Sphinx so it can automatically generate a pydoc for my python code but I\'m getting an error. What an I doing wrong?

conf.py sphinx config

5条回答
  •  既然无缘
    2021-02-07 02:08

    I came to this question via Google, so I'll answer what helped me (not directly related to the question).

    I use importlib to dynamically import sub-packages given by a string.

    import importlib
    module_name = 'subpackage.i.import'
    special_module = importlib.import_module(module_name, package=None)
    

    This simply has to be adjusted to

    import importlib
    module_name = 'subpackage.i.import'
    special_module = importlib.import_module(module_name, package='my_current_pkg')
    

提交回复
热议问题