首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sphinx Autodoc未正确导入

Sphinx Autodoc未正确导入
EN

Stack Overflow用户
提问于 2012-01-23 23:32:15
回答 1查看 1.3K关注 0票数 1

正如标题所说,我正在使用Sphinx为python库生成文档,并使用auto doc函数。

我遇到的问题是autodoc导入器没有正确地导入库。

代码语言:javascript
复制
Traceback (most recent call last):rs/user                                                                                                                                                         
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/decorators.py", line 4, in <module>
    import response
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/response.py", line 2, in <module>
    from lib.helpers import gtJSONEncoder
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/helpers.py", line 3, in <module>
    from gt import Model, EMAIL_FROM, EMAIL_HOST
  File "/Users/prggmr/Work/chevy/gt/software/gt/gt.py", line 114, in <module>
    from modules.user import views
  File "/Users/prggmr/Work/chevy/gt/software/gt/modules/user/views.py", line 5, in <module>
    from lib import response
ImportError: cannot import name response
Traceback (most recent call last):json                                                                                                                                                            
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/helpers.py", line 2, in <module>
    import response
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/response.py", line 2, in <module>
    from lib.helpers import gtJSONEncoder
ImportError: cannot import name gtJSONEncoder
Traceback (most recent call last):messages                                                                                                                                                        
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named helper
Traceback (most recent call last):request                                                                                                                                                         
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/helpers.py", line 2, in <module>
    import response
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/response.py", line 2, in <module>
    from lib.helpers import gtJSONEncoder
ImportError: cannot import name gtJSONEncoder
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/helpers.py", line 2, in <module>
    import response
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/response.py", line 2, in <module>
    from lib.helpers import gtJSONEncoder
ImportError: cannot import name gtJSONEncoder
Traceback (most recent call last):ser                                                                                                                                                             
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/modules/user/models.py", line 6, in <module>
    import gt
  File "/Users/prggmr/Work/chevy/gt/software/gt/gt.py", line 114, in <module>
    from modules.user import views
  File "/Users/prggmr/Work/chevy/gt/software/gt/modules/user/views.py", line 7, in <module>
    from lib.decorators import valid_user
  File "/Users/prggmr/Work/chevy/gt/software/gt/lib/decorators.py", line 7, in <module>
    from gt.modules.user.models import get_user_account, is_login_valid
ImportError: No module named modules.user.models
Traceback (most recent call last):ser                                                                                                                                                             
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.1.2-py2.7.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
  File "/Users/prggmr/Work/chevy/gt/software/gt/modules/user/views.py", line 2, in <module>
    from gt import app, TEMPLATES_PATH
  File "/Users/prggmr/Work/chevy/gt/software/gt/gt.py", line 114, in <module>
    from modules.user import views
ImportError: cannot import name views

我已经三次检查了路径是否正确,并将它们包含在系统路径中。

真正让我着迷的是,我可以完美地运行应用程序,并且所有单元测试都能通过,代码覆盖率超过95%……然而,狮身人面像无法导入它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-24 02:38:50

这看起来像是一个导入循环。尝试组织您的导入,使它们不会在循环中相互依赖。

或者,您可以尝试对它们进行重新排序。也许在helpers.py中,将第3行移动到文件的底部,或者类似的东西。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8974115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档