2012-01-23 29 views
1

正如標題所說,我正在使用Sphinx來爲python庫生成文檔並使用自動文檔功能。Sphinx Autodoc沒有正確導入

我遇到的問題是autodoc導入程序沒有正確導入這些庫。

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%的代碼覆蓋率......但獅身人面像無法導入它。

+0

你能告訴我們關於圖書館的更多細節嗎?它是純粹的Python嗎? – mzjn

+0

是的,圖書館是我目前正在建造的一個自定義應用程序。 – Nick

回答

2

看起來像一個導入循環。嘗試組織你的導入,以便它們不依賴於一個圈子中的對方。

或者,您可以嘗試對它們重新排序。也許在helpers.py將第3行移到文件的底部,或類似的東西。

+0

究竟是什麼!謝謝! – Nick