2013-07-28 8 views
15

私は実際のプロジェクトでそれを実行する前に、テストPythonプロジェクトのドキュメントを作成しようとしています。 私のシステム:Win7 64ビット、Python 2.7.5 64ビット。autodocを使用しているときにSphinxがPythonパッケージを見つけられない

私のプロジェクト名はです。testDocです。 tという名前のPythonパッケージが含まれており、2つのモジュールt1t2__init__.pyが含まれています。

__init__.pyは含まれています

import t1 
import t2 

t1.pyは含まれています

''' 
Created on 27 2013 

@author: 
''' 

class MyClass(object): 
    ''' 
    Hi 
    ''' 


    def __init__(self,selfparams): 
     ''' 
     Constructor 
     ''' 
     pass 

testDocに、私は、コマンドラインで実行するドキュメントを作成するには:

sphinx-apidoc -A "me" -F -o docs . 

スフィンクスは多くを作成しますファイルとそれはスフィンクスdによると大丈夫ですocs。

Making output directory... 
Running Sphinx v1.1.3 
loading pickled environment... not yet created 
building [html]: targets for 2 source files that are out of date 
updating environment: 2 added, 0 changed, 0 removed 
reading sources... [ 50%] index 
reading sources... [100%] t 
Traceback (most recent call last): 
    File "C:\Python27\lib\site-packages\sphinx\ext\autodoc.py", line 321, in impor 
t_object 
    __import__(self.modname) 
ImportError: No module named t.__init__ 
Traceback (most recent call last): 
    File "C:\Python27\lib\site-packages\sphinx\ext\autodoc.py", line 321, in impor 
t_object 
    __import__(self.modname) 
ImportError: No module named t.t1 
Traceback (most recent call last): 
    File "C:\Python27\lib\site-packages\sphinx\ext\autodoc.py", line 321, in impor 
t_object 
    __import__(self.modname) 
ImportError: No module named t.t2 

...testDoc\t\docs\t.rst:7: WARNING: a 
autodoc can't import/find module 't.__init__', it reported error: "No module name 
d t.__init__", please check your spelling and sys.path 
...testDoc\t\docs\t.rst:15: WARNING: 
autodoc can't import/find module 't.t1', it reported error: "No module named t.t 
1", please check your spelling and sys.path 
t...testDoc\t\docs\t.rst:23: WARNING: 
autodoc can't import/find module 't.t2', it reported error: "No module named t.t 
2", please check your spelling and sys.path 
looking for now-outdated files... none found 
pickling environment... done 
checking consistency... done 
preparing documents... done 
writing output... [ 50%] index 
writing output... [100%] t 

writing additional files... (0 module code pages) genindex search 
copying static files... done 
dumping search index... done 
dumping object inventory... done 
build succeeded, 3 warnings. 

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

何が問題になっています: その後、conf.pyは私がドキュメントフォルダを入力して、次の誤った出力を

make html 

を入力してもらう

sys.path.insert(0, os.path.abspath(absolute path to testDoc)) 

が変更されましたか?おかげさまで

+0

私の推測では、testDoc'への絶対パスを 'に何か問題があるということです。 'os.path.abspath(" .. ")'を使うことはできませんか? – mzjn

+0

@mzjnありがとうございました。しかし、同じ問題が発生します。 – user1264304

答えて

19

"testDocへの絶対パス"は何か分かりませんが、Sphinxの出力からは、testDocディレクトリ構造がtestDoc/t/docsであることがわかります。 docsディレクトリはconf.pyの場所です。モジュール検索パスの場合

が正しく設定されるように、あなたはconf.pyから最大2つのレベルを移動する必要があります:

sys.path.insert(0, os.path.abspath("../..")) 
+0

@ mzjnありがとう。出来た。絶対パスではそれはしませんでした。 – user1264304

+0

私はそれを行いました、モジュールを実行するパスを追加しましたが、それでもコンパイルされ、モジュールは表示されません!何かご意見は ? –

+0

@PedroBraz:良い提案を思いつくのは難しいです。すべてのプロジェクトが異なり、私はあなたのことについて何も知らない。 – mzjn

関連する問題