简体   繁体   English

Python Sphinx 中的“No module named”几个导入错误

[英]“No module named” several import errors in Python Sphinx

I am new to sphinx documentation.我是 sphinx 文档的新手。 I followed the sphinx documentation for configuring sphinx for my cherrypy project.But when I run make html it throws me lots of errors and warnings as follows:我按照sphinx 文档为我的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.

Any hope ?有希望吗? someone please help.. I have also changed the line in my conf.py as follows:有人请帮忙..我也改变了我的conf.py中的行如下:

sys.path.append('workspace/myproject/src/myproject/')

myproject is a module. myproject是一个模块。 You have thus to add its parent container to the PYTHONPATH (and not the myproject-folder itself):因此,您必须将其父容器添加到 PYTHONPATH(而不是 myproject 文件夹本身):

sys.path.append('workspace/myproject/src/')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM