Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python sphinx构建失败-autodoc可以';导入/查找模块_Python_Python Sphinx_Autodoc - Fatal编程技术网

Python sphinx构建失败-autodoc可以';导入/查找模块

Python sphinx构建失败-autodoc可以';导入/查找模块,python,python-sphinx,autodoc,Python,Python Sphinx,Autodoc,我试着从狮身人面像开始,似乎遇到了无情的问题 命令:docs/sphinx快速启动 我回答了所有的问题,一切都很好 命令:docs/ls 一切看起来都很正常。结果:buildmakefile源代码 命令:sphinx build-d build/doctrees源代码build/html 它似乎起作用了。我能够打开index.html文件,看到我想要的东西的“外壳” 当我尝试将实际的源代码作为source文件夹时,我遇到了问题 命令:sphinx build-d build/doctrees..

我试着从狮身人面像开始,似乎遇到了无情的问题

命令:
docs/sphinx快速启动

我回答了所有的问题,一切都很好

命令:
docs/ls

一切看起来都很正常。结果:
buildmakefile源代码

命令:
sphinx build-d build/doctrees源代码build/html

它似乎起作用了。我能够打开index.html文件,看到我想要的东西的“外壳”

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

命令:
sphinx build-d build/doctrees../ys\u utils build/html

结果:

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!
正在生成输出目录。。。
运行Sphinx v1.1.3
正在加载酸洗环境。。。尚未创建
未选择任何生成器,使用默认值:html
从中加载intersphinx资源清册http://docs.python.org/objects.inv...
building[html]:1个过期源文件的目标
更新环境:添加1个,更改0个,删除0个
回溯(最近一次呼叫最后一次):
导入对象中的文件“/usr/local/lib/python2.6/dist packages/Sphinx-1.1.3-py2.6.egg/Sphinx/ext/autodoc.py”,第321行
__导入(self.modname)
ImportError:没有名为ys_utils的模块
回溯(最近一次呼叫最后一次):
导入对象中的文件“/usr/local/lib/python2.6/dist packages/Sphinx-1.1.3-py2.6.egg/Sphinx/ext/autodoc.py”,第321行
__导入(self.modname)
ImportError:没有名为ys\u utils.test\u validate\u ut的模块
回溯(最近一次呼叫最后一次):
导入对象中的文件“/usr/local/lib/python2.6/dist packages/Sphinx-1.1.3-py2.6.egg/Sphinx/ext/autodoc.py”,第321行
__导入(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行
__导入(self.modname)
ImportError:没有名为setup.setup的模块
/home/ricomos/workspace/nextgen/ys_utils/ys_utils.rst:4:警告:autodoc无法导入/查找模块“ys_utils”,它报告了错误:“没有名为ys_utils的模块”,请检查拼写和sys.path
/home/ricomos/workspace/nextgen/ys_utils/ys_utils.rst:10:警告:autodoc无法导入/查找模块“ys_utils.test_validate_ut”,它报告了错误:“没有名为ys_utils.test_validate_ut的模块”,请检查拼写和sys.path
/home/ricomos/workspace/nextgen/ys_-utils/ys_-utils.rst:12:警告:不知道要导入哪个模块以自动记录u'UnitTests(尝试在文档中放置“module”或“currentmodule”指令,或给出明确的模块名称)
/home/ricomos/workspace/nextgen/ys_-utils/ys_-utils.rst:18:警告:autodoc无法导入/查找模块“ys_-utils.git_-utils”,它报告了错误:“没有名为ys_-utils.git_-utils的模块”,请检查拼写和sys.path
/home/ricomos/workspace/nextgen/ys_utils/ys_utils.rst:24:警告:autodoc无法导入/查找模块'setup.setup',它报告错误:“没有名为setup.setup的模块”,请检查拼写和sys.path
警告:找不到主文件/home/ricomos/workspace/nextgen/ys_utils/index.rst
正在查找现在过时的文件。。。找不到
酸洗环境。。。完成
正在检查一致性/home/ricomos/workspace/nextgen/ys_utils/ys_utils.rst::警告:任何目录树中都不包含文档
完成
正在准备文档。。。完成
正在写入输出。。。[50%]指数
发生异常:
get_doctree中的文件“/usr/local/lib/python2.6/dist packages/Sphinx-1.1.3-py2.6.egg/Sphinx/environment.py”,第1213行
f=打开(doctree\u文件名'rb')
IOError:[Errno 2]没有这样的文件或目录:'/home/ricomos/workspace/nextgen/docs/build/doctrees/index.doctree'
如果要向开发人员报告问题,则完整的回溯已保存在/tmp/sphinx-err-j7gm.log中。
如果是用户错误,也请报告,以便下次提供更好的错误消息。
或者将Bug发送到以下地址的邮件列表:,
或者在追踪器中报告。谢谢
我对斯芬克斯是一个完全的新手,对这类文档也比较陌生。有人能提供一些建议吗

编辑:

我希望能够使用Makefile来处理这个问题。到目前为止,我的项目中有两个文件夹

nextgen/ls

docs ys_utils


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

我想我第一次尝试将文件添加到目录树时就这样做了。我想是因为我在Max深度线和文件名之间省去了空白行。

.. Animatrix Concepts documentation master file, created by
   sphinx-quickstart on Thu Mar 22 18:06:15 2012.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to Animatrix Concepts documentation!
============================================

Contents:

.. toctree::
   :maxdepth: 2

   stuff


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

上面是我的index.rst文件。stuff.rst与它位于同一目录中。

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

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

顺便说一下:您可以使用Sphinx创建的
Makefile
来创建文档。 就打电话

make
查看选项

如果在尝试之前出现问题:

make clean

在运行
之前,在
conf.py

只需将路径添加到项目文件夹

sys.path.append('/home/workspace/myproj/myproj')
您可以使用和noweb格式生成rst文档,其中包含嵌入其中的代码的输出。基本上,您编写rst文件,python代码嵌入到标记块中,如下所示:

<<echo=False>>=
print("some text that will appear in the rst file")
@
=
打印(“将出现在rst文件中的某些文本”)
@
Pweave将执行这些块,并在re中用它们的输出替换它们
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../..'))
.. automethod:: mymodule::func
project_dir
|- setup.py
|- src
|  |- __init__.py
|  |- source1.py
|  |- sub_project
|     |- __init__.py
|     |- source2.py 
|- docs
    |- conf.py
    |- source
    |  |- index.rst
    |- _build       
for x in os.walk('../../src'):
  sys.path.insert(0, x[0])