本文介绍了sphinx-build fail - autodoc无法导入/查找模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



命令: docs / sphinx-quickstart



我回答所有问题,一切正常。



命令: docs / ls



一切看起来都很正常。结果:构建Makefile源



命令: sphinx-build -d build / doctrees source build / html



似乎有效。我能够打开index.html文件,看到我想要的shell。



当我尝试将我的实际源代码作为 source 文件夹我遇到问题。



命令: sphinx-build -d build / doctrees ../ys_utils build / html



结果:

 code>输出目录... 
运行Sphinx v1.1.3
加载腌制环境...尚未创建
未选择构建器,使用默认值:html
加载来自http://docs.python.org/objects.inv ...
建筑物[html]:1个源文件的目标已过期
更新环境:添加1,更改0 ,0已删除
追溯(最近的最后一次调用):
文件/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ ext / autodoc.py,第321行,在import_object
__import __(self.modname)
Im portError:没有名为ys_utils
的模块追溯(最近的最后一次调用):
文件/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg /sphinx/ext/autodoc.py,第321行,在import_object
__import __(self.modname)
ImportError:没有名为ys_utils.test_validate_ut的模块
追溯(最近的最后一次呼叫):
文件/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py,第321行,在import_object
__import __(self.modname)
ImportError:没有名为ys_utils.git_utils的模块
追溯(最近的最后一次调用):
文件/usr/local/lib/python2.6/dist-packages /Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py,第321行,在import_object
__import __(self.modname)
ImportError:没有名为setup.setup的模块b
$ b /home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:4:警告:autodoc无法导入/查找模块'ys_utils',它报告错误:没有模块名为ys_utils,请检查你的拼写d sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:10:警告:autodoc无法导入/查找模块'ys_utils.test_validate_ut',它报告错误:没有名为ys_utils的模块.test_validate_ut,请检查您的拼写和sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:12:警告:不知道导入哪个模块以自动记录u'UnitTests'(尝试在文档中放置module或currentmodule指令,或者给出明确的模块名称)
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:18:警告:autodoc无法导入/ find module'ys_utils.git_utils',它报告错误:没有模块名为ys_utils.git_utils,请检查您的拼写和sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:24 :警告:autodoc无法导入/查找模块'setup.setup',它报告错误:没有模块名为setup.setup,请检查您的拼写和sys.path
警告:主文件/ home / ricomoss /工作空间/ nextgen / ys_utils / index.rst未找到
寻找现在过时的文件...没有找到
酸洗环境...完成
检查一致性... / home / ricomoss /工作区/ nextgen / ys_utils / ys_utils.rst ::警告:文件不包括在任何toctree
中完成
准备文件...完成
写入输出... [50%]索引
异常发生:
文件/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/environment.py,第1213行,在get_doctree
f = open(doctree_filename,'rb')
IOError:[Errno 2]没有这样的文件或目录:'/home/ricomoss/workspace/nextgen/docs/build/doctrees/index.doctree '
如果要将问题报告给开发人员,完整的追溯保存在/tmp/sphinx-err-jjJ7gM.log中。
如果是用户错误,请同时举报,以便下次提供更好的错误信息。
发送错误到邮件列表< http://groups.google.com/group/sphinx-dev/>
或者在跟踪器中的< http:// bitbucket.org/birkenfeld/sphinx/issues/> ;.谢谢!

我是Sphinx的一个完整的新手,对这种文档来说比较新。任何人都可以提供一些建议?



编辑:



我想要使用Makefile处理这个(事情。到目前为止,我的项目中有两个文件夹。



nextgen / ls



docs ys_utils



我需要 nextgen / docs / Makefile ys_utils 和我将要拥有的所有其他模块生成HTML

解决方案

Autodoc找不到您的模块,因为它们不在 sys.path 中。



您必须在 sys.path 中包含模块的路径> conf.py 。
查看 conf.py 的顶部(刚刚导入 sys ),有一个 sys.path.insert()语句,您可以调整。



顺便说一句:您可以使用由Sphinx创建的 Makefile 来创建文档。
只需调用

  make 

查看选项。



如果在尝试之前发生错误:

  make clean 

在运行 make html


I'm trying to get started with Sphinx and seem to have relentless problems.

Command: docs/sphinx-quickstart

I answer all the questions and everything works fine.

Command: docs/ls

Everything looks normal. Result: build Makefile source

Command: sphinx-build -d build/doctrees source build/html

It seems to work. I was able to open the index.html file and see a "shell" of what I'm wanting.

When I try and put my actual source code as the source folder I run into problems.

Command: sphinx-build -d build/doctrees ../ys_utils build/html

Result:

Making output directory...
Running Sphinx v1.1.3
loading pickled environment... not yet created
No builder selected, using default: html
loading intersphinx inventory from http://docs.python.org/objects.inv...
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils.test_validate_ut
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils.git_utils
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named setup.setup

/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:4: WARNING: autodoc can't import/find module 'ys_utils', it reported error: "No module named ys_utils", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:10: WARNING: autodoc can't import/find module 'ys_utils.test_validate_ut', it reported error: "No module named ys_utils.test_validate_ut", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:12: WARNING: don't know which module to import for autodocumenting u'UnitTests' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:18: WARNING: autodoc can't import/find module 'ys_utils.git_utils', it reported error: "No module named ys_utils.git_utils", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:24: WARNING: autodoc can't import/find module 'setup.setup', it reported error: "No module named setup.setup", please check your spelling and sys.path
WARNING: master file /home/ricomoss/workspace/nextgen/ys_utils/index.rst not found
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [ 50%] index
Exception occurred:
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/environment.py", line 1213, in get_doctree
    f = open(doctree_filename, 'rb')
IOError: [Errno 2] No such file or directory: '/home/ricomoss/workspace/nextgen/docs/build/doctrees/index.doctree'
The full traceback has been saved in /tmp/sphinx-err-jjJ7gM.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.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!

I am a complete newbie to Sphinx and relatively new to this kind of documentation. Can anyone offer some suggestions?

Edit:

I'd like to be able to use a Makefile to handle this. As of now I have two folders in my project.

nextgen/ls

docs ys_utils

I need nextgen/docs/Makefile to generate the HTML for ys_utils and all other modules I'm going to have.

解决方案

Autodoc can't find your modules, because they are not in sys.path.

You have to include the path to your modules in in the sys.path in your conf.py.Look at the top of your conf.py (just after the import of sys), there is a sys.path.insert() statement, which you can adapt.

By the way: you can use the Makefile created by Sphinx to create your documentation.Just call

make

to see the options.

If something went wrong before try:

make clean

before running make html.

这篇关于sphinx-build fail - autodoc无法导入/查找模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:29
查看更多