在Python Sphinx中出现了几个导入错误,"没有模块命名"。

问题描述 投票:1回答:1

我是新来的斯芬克斯文档。我按照 狮身人面像文件 为我的cherrypy项目配置sphinx.但当我运行 make html 它给我扔了很多错误和警告如下。

Traceback (most recent call last):.root                                                                                                                                                         
File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
ImportError: No module named myproject.apps.root.urls
Traceback (most recent call last):
File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
ImportError: No module named myproject.apps.root.views
Traceback (most recent call last):.search                                                                                                                                                       
 File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in       import_object                                                                  
__import__(self.modname)                                                                                                                                                                    
ImportError: No module named myproject.apps.search.searchBll                                                                                                                                          
Traceback (most recent call last):                                                                                                                                                              
File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in import_object                                                                  
__import__(self.modname)                                                                                                                                                                    
ImportError: No module named myproject.apps.search.searchDal                                                                                                                                          
Traceback (most recent call last):
File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
ImportError: No module named myproject.apps.search.urls
Traceback (most recent call last):
File "workspace/myproject-virtualenv/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
ImportError: No module named myproject.apps.search.views
.
.
.
workspace/myproject/docs/api_doc/source/myproject.apps.root.rst:7: WARNING: autodoc can't   import/find module 'myproject.apps.root.urls', it reported error: "No module named myproject.apps.root.urls", please check your spelling and sys.path
workspace/myproject/docs/api_doc/source/myproject.apps.root.rst:15: WARNING: autodoc can't import/find module 'myproject.apps.root.views', it reported error: "No module named myproject.apps.root.views", please check your spelling and sys.path
workspace/myproject/docs/api_doc/source/myproject.apps.search.rst:7: WARNING: autodoc can't import/find module 'myproject.apps.search.searchBll', it reported error: "No module named myproject.apps.search.searchBll", please check your spelling and sys.path
workspace/myproject/docs/api_doc/source/myproject.apps.search.rst:15: WARNING: autodoc can't import/find module 'myproject.apps.search.searchDal', it reported error: "No module named myproject.apps.search.searchDal", please check your spelling and sys.path
workspace/myproject/docs/api_doc/source/myproject.apps.search.rst:23: WARNING: autodoc can't import/find module 'myproject.apps.search.urls', it reported error: "No module named myproject.apps.search.urls", please check your spelling and sys.path
workspace/myproject/docs/api_doc/source/myproject.apps.search.rst:31: WARNING: autodoc can't import/find module 'myproject.apps.search.views', it reported error: "No module named myproject.apps.search.views", please check your spelling and sys.path

looking for now-outdated files... none found
pickling environment... done
checking consistency... workspace/myproject/docs/api_doc/source/modules.rst::       WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%]   modules                                                                                                                                                                
writing additional files... (0 module code pages) genindex search
copying static files... done
dumping search index... done
dumping object inventory... done
build succeeded, 21 warnings.

Build finished. The HTML pages are in build/html.

希望有人能帮帮我... 我也修改了conf.py中的一行如下。

sys.path.append('workspace/myproject/src/myproject/')
python python-sphinx cherrypy
1个回答
3
投票

myproject 是一个模块。因此你必须将它的父容器添加到PYTHONPATH中(而不是myproject-文件夹本身)。

sys.path.append('workspace/myproject/src/')
© www.soinside.com 2019 - 2024. All rights reserved.