Sphinx无法记录flask项目,因为导入了当前的\u应用程序

2024-09-30 14:16:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经设置了Sphinx来记录我的烧瓶项目,但是,我遇到了这个错误:

[$]>>> make html
sphinx-build -b html -d build/doctrees  -W -v source build/html
Running Sphinx v1.4.5
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 5 source files that are out of date
updating environment: 5 added, 0 changed, 0 removed
reading sources... [ 20%] index
reading sources... [ 40%] modules
reading sources... [ 60%] quizApp
Traceback (most recent call last):
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/viewcode.py", line 28, in _get_full_modname
    return get_full_modname(modname, attribute)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/util/__init__.py", line 300, in get_full_modname
    __import__(modname)
TypeError: __import__() argument 1 must be string, not None
viewcode can't import None, failed with error "__import__() argument 1 must be string, not None"
Traceback (most recent call last):
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/viewcode.py", line 28, in _get_full_modname
    return get_full_modname(modname, attribute)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/util/__init__.py", line 300, in get_full_modname
    __import__(modname)
TypeError: __import__() argument 1 must be string, not None
viewcode can't import None, failed with error "__import__() argument 1 must be string, not None"
Didn't find ParticipantExperiment.activities in quizApp.models
Didn't find Question.explantion in quizApp.models
Didn't find User.name in quizApp.models
Didn't find User.authenticated in quizApp.models
reading sources... [ 80%] quizApp.forms
reading sources... [100%] quizApp.views

Traceback (most recent call last):
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/cmdline.py", line 244, in main
    app.build(opts.force_all, filenames)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/application.py", line 297, in build
    self.builder.build_update()
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 251, in build_update
    'out of date' % len(to_build))
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 265, in build
    self.doctreedir, self.app))
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/environment.py", line 569, in update
    self._read_serial(docnames, app)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/environment.py", line 589, in _read_serial
    self.read_doc(docname, app)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/environment.py", line 742, in read_doc
    pub.publish()
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/core.py", line 217, in publish
    self.settings)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/io.py", line 49, in read
    self.parse()
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/__init__.py", line 172, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 170, in run
    input_source=document['source'])
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2726, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 239, in run
    context, state, transitions)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2299, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2311, in explicit_construct
    return method(self, expmatch)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2054, in directive
    directive_class, match, type_name, option_presets)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/docutils/parsers/rst/states.py", line 2103, in run_directive
    result = directive_instance.run()
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 1613, in run
    documenter.generate(more_content=self.content)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 963, in generate
    self.document_members(all_members)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 855, in document_members
    if cls.can_document_member(member, mname, isattr, self)]
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 1458, in can_document_member
    isdatadesc = isdescriptor(member) and not \
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/util/inspect.py", line 101, in isdescriptor
    if hasattr(safe_getattr(x, item, None), '__call__'):
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/sphinx/util/inspect.py", line 113, in safe_getattr
    if name in obj.__dict__:
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/werkzeug/local.py", line 343, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/werkzeug/local.py", line 302, in _get_current_object
    return self.__local()
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/flask/globals.py", line 37, in _lookup_req_object
    raise RuntimeError(_request_ctx_err_msg)
RuntimeError: Working outside of request context.

This typically means that you attempted to use functionality that needed
an active HTTP request.  Consult the documentation on testing for
information about how to avoid this problem.

Exception occurred:
  File "/home/alyosha/.virtualenvs/quizApp-new/lib/python2.7/site-packages/flask/globals.py", line 37, in _lookup_req_object
    raise RuntimeError(_request_ctx_err_msg)
RuntimeError: Working outside of request context.

This typically means that you attempted to use functionality that needed
an active HTTP request.  Consult the documentation on testing for
information about how to avoid this problem.
The full traceback has been saved in /tmp/sphinx-err-iI83eY.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make: *** [Makefile:53: html] Error 1

经过一番挖掘,我发现问题是因为这句话:

https://github.com/PlasmaSheep/sphinx-error/blob/master/app/issue.py

请在此处查看完整的最小示例:

https://github.com/PlasmaSheep/sphinx-error


Tags: inpyselfhomenewlibpackagessphinx
1条回答
网友
1楼 · 发布于 2024-09-30 14:16:06

问题是斯芬克斯。Sphinx1.4.5包含导致此行为的错误。这可以通过从git安装sphinx来解决。希望他们能很快推出一个新版本给pypi。在

编辑:斯芬克斯1.4.4也可以。在

相关问题 更多 >

    热门问题