python - Sphinx autodoc in Flask ImportError: no module named -
i'm trying set sphinx autodoc flask project. here schema of project:
folder |--docs | |--build | |--source | conf.py | index.rst | mod_ololo.rst | .... |--flask_app | |--celery_worker.py | |--config.py | |--run.py | |--app | |--__init__.py | |--temp.py | |--mod_search | .... | |--mod_files | |--__init__.py | ....
and on.
in conf.py set:
sys.path.insert(0, os.path.abspath("../.."))
i'm trying add content of temp.py documentation. here content of mod_ololo.rst:
******************************************* ololo module ******************************************* ololololo ====== .. automodule:: flask_app.app.temp :members:
and when run make html
separate scripts - sphinx autodoc works, in case of flask project doesn't , shows me following error:
importerror: no module named 'config'
where config config.py
purely guess, config
module sphinx builder isn't finding config.py
module in flask_app
folder. there's import config
statement somewhere in flask_app/app/temp.py
file, when sphinx tries run automodule
procedure on it, gets failure on import.
from directory structure looks flask_app
folder not python package, might have add folder rather (or in addition to) parent folder path
in conf.py
file:
sys.path.insert(0, os.path.abspath('../../flask_app'))
also, you'll have change automodule statement in mod_ololo.rst
not reference flask_app
package:
.. automodule:: app.temp
if do intend use flask_app
package, need __init__.py
file in folder, , import statements within project should absolute top flask_app
package, i.e.:
from flask_app import config
rather than
import config
Comments
Post a Comment