尽管在$ PATH中,Sphinx仍未找到模块

时间:2018-08-10 10:33:44

标签: python python-sphinx

make htmlsphinx-apidoc期间没有错误。
但是

之后
sphinx-build -b html ./rst/ ./html/ 

我得到:

WARNING: autodoc: failed to import module u'mcp.mcp.ann_mcp'; the following 
  exception was raised: No module named mcp.ann_mcp

在config.py中,我添加了:

import os
import sys
sys.path.append('/home/neurodad/source')
sys.path.append('/home/neurodad/source/mcp')
sys.path.append('/home/neurodad/source/mcp/mcp')
print "PATH:", sys.path

和sys.path的打印输出给我:

PATH: ['/home/neurodad/miniconda2/envs/prod_keras/bin', '/home/neurodad/miniconda2/envs/prod_keras/lib/python27.zip', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7/plat-linux2', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7/lib-tk', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7/lib-old', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7/lib-dynload', '/home/neurodad/miniconda2/envs/prod_keras/lib/python2.7/site-packages', '/home/neurodad/source/outlierdetector', '/home/neurodad/source/databalancer', '/home/neurodad/source/datanexus', '/home/neurodad/source/distributiontransformer', '/home/neurodad/source/mcp', '/home/neurodad/source/optimization', '/home/neurodad/source/setmaker', '/home/neurodad/source/zswtools', '/home/neurodad/source/supervisedlearning', '/home/neurodad/source', '/home/neurodad/source', '/home/neurodad/source/mcp', '/home/neurodad/source/mcp/mcp']

我搜索了网络,但是每个与我的问题有关的技巧都是“将源路径添加到您的conf.py”。 我没主意-希望您能提供帮助。 非常感谢!

更新: 我做了最少的代码:

class dummy(object):
    def __init__(self, d1):
        self.d1 = d1

    def dummy_method(self, d2):
        """
        Args:
            d2 (str): second test string.

        Example:
            '>>> my_dummy = dummy("Hello World!")'
            '>>> my_dummy.dummy_method("Hello Back.")'
            Hello World! Hello Back.
        """
        print self.d1, d2
if __name__ == '__main__':
    my_dummy = dummy("Hello World!")
    my_dummy.dummy_method("Hello Back.")

conda软件包列表在这里:

# Name                    Version                   Build  Channel
_tflow_190_select         0.0.1                       gpu  
absl-py                   0.3.0                    py27_0  
alabaster                 0.7.11                   py27_0  
asn1crypto                0.24.0                   py27_0  
astor                     0.7.1                    py27_0  
attrdict                  2.0.0                      py_1    conda-forge
babel                     2.6.0                    py27_0  
backports                 1.0                      py27_1  
backports.functools_lru_cache 1.5                      py27_1  
backports.weakref         1.0.post1                py27_0  
backports_abc             0.5                      py27_0  
beautifulsoup4            4.6.1                    py27_0  
blas                      1.0                         mkl  
ca-certificates           2018.03.07                    0  
certifi                   2018.4.16                py27_0  
cffi                      1.11.5           py27h9745a5d_0  
chardet                   3.0.4                    py27_1  
conda                     4.5.9                    py27_0  
conda-build               3.12.1                   py27_0  
conda-env                 2.6.0                         1  
contextlib2               0.5.5                    py27_0  
cryptography              2.3              py27hb7f436b_0  
cryptography-vectors      2.3                      py27_0  
cudatoolkit               9.0                  h13b8566_0  
cudnn                     7.1.2                 cuda9.0_0  
cupti                     9.0.176                       0  
cycler                    0.10.0           py27hc7354d3_0  
dbus                      1.13.2               h714fa37_1  
docutils                  0.14                     py27_0  
enum34                    1.1.6                    py27_1  
expat                     2.2.5                he0dffb1_0  
filelock                  3.0.4                    py27_0  
fontconfig                2.13.0               h9420a91_0  
freetype                  2.9.1                h8a8886c_0  
funcsigs                  1.0.2                    py27_0  
functools32               3.2.3.2                  py27_1  
futures                   3.2.0                    py27_0  
gast                      0.2.0                    py27_0  
glib                      2.56.1               h000015b_0  
glob2                     0.6                      py27_0  
grpcio                    1.12.1           py27hdbcaa40_0  
gst-plugins-base          1.14.0               hbbd80ab_1  
gstreamer                 1.14.0               hb453b48_1  
h5py                      2.8.0            py27h8d01980_0  
hdf5                      1.10.2               hba1933b_1  
icu                       58.2                 h9c2bf20_1  
idna                      2.7                      py27_0  
imagesize                 1.0.0                    py27_0  
intel-openmp              2018.0.3                      0  
ipaddress                 1.0.22                   py27_0  
jinja2                    2.10                     py27_0  
jpeg                      9b                   h024ee3a_2  
keras                     2.2.2                         0  
keras-applications        1.0.4                    py27_0  
keras-base                2.2.2                    py27_0  
keras-preprocessing       1.0.2                    py27_0  
kiwisolver                1.0.1            py27hf484d3e_0  
libedit                   3.1.20170329         h6b74fdf_2  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran-ng            7.2.0                hdf63c60_3  
libpng                    1.6.34               hb9fc6fc_0  
libprotobuf               3.5.2                h6f1eeef_0  
libstdcxx-ng              7.2.0                hdf63c60_3  
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.8                h26e45fe_1  
linecache2                1.0.0                    py27_0  
markdown                  2.6.11                   py27_0  
markupsafe                1.0              py27h14c3975_1  
matplotlib                2.2.2            py27hb69df0a_2  
mkl                       2018.0.3                      1  
mkl_fft                   1.0.4            py27h4414c95_1  
mkl_random                1.0.1            py27h4414c95_1  
mock                      2.0.0            py27h0c0c831_0  
ncurses                   6.1                  hf484d3e_0  
numpy                     1.15.0           py27h1b885b7_0  
numpy-base                1.15.0           py27h3dfced4_0  
openssl                   1.0.2o               h14c3975_1  
packaging                 17.1                     py27_0  
pandas                    0.23.4           py27h04863e7_0  
patchelf                  0.9                  hf484d3e_2  
patsy                     0.5.0                    py27_0  
pbr                       4.2.0                    py27_0  
pcre                      8.42                 h439df22_0  
pip                       10.0.1                   py27_0  
pkginfo                   1.4.2                    py27_1  
protobuf                  3.5.2            py27hf484d3e_1  
psutil                    5.4.6            py27h14c3975_0  
pycosat                   0.6.3            py27h14c3975_0  
pycparser                 2.18                     py27_1  
pygments                  2.2.0            py27h4a8b6f5_0  
pyopenssl                 18.0.0                   py27_0  
pyparsing                 2.2.0                    py27_1  
pyqt                      5.9.2            py27h22d08a2_0  
pysocks                   1.6.8                    py27_0  
python                    2.7.15               h1571d57_0  
python-dateutil           2.7.3                    py27_0  
pytz                      2018.5                   py27_0  
pyyaml                    3.13             py27h14c3975_0  
qt                        5.9.6                h52aff34_0  
readline                  7.0                  ha6073c6_4  
requests                  2.19.1                   py27_0  
ruamel_yaml               0.15.46          py27h14c3975_0  
scandir                   1.8              py27h14c3975_0  
scikit-learn              0.19.1           py27hedc7406_0  
scipy                     1.1.0            py27hc49cb51_0  
seaborn                   0.9.0                    py27_0  
setuptools                39.2.0                   py27_0  
singledispatch            3.4.0.3                  py27_0  
sip                       4.19.8           py27hf484d3e_0  
six                       1.11.0                   py27_1  
snowballstemmer           1.2.1                    py27_0  
sphinx                    1.7.6                    py27_0  
sphinxcontrib             1.0                      py27_1  
sphinxcontrib-websupport  1.1.0                    py27_1  
sqlite                    3.24.0               h84994c4_0  
statsmodels               0.9.0            py27h035aef0_0  
subprocess32              3.5.2            py27h14c3975_0  
tensorboard               1.9.0            py27hf484d3e_0  
tensorflow                1.9.0           gpu_py27hd3a791e_1  
tensorflow-base           1.9.0           gpu_py27h6ecc378_0  
tensorflow-gpu            1.9.0                hf154084_0  
termcolor                 1.1.0                    py27_1  
tk                        8.6.7                hc745277_3  
tornado                   5.0.2            py27h14c3975_0  
traceback2                1.4.0                    py27_0  
typing                    3.6.4                    py27_0  
unittest2                 1.1.0                    py27_0  
urllib3                   1.23                     py27_0  
werkzeug                  0.14.1                   py27_0  
wheel                     0.31.1                   py27_0  
xz                        5.2.4                h14c3975_4  
yaml                      0.1.7                had09818_2  
zlib                      1.2.11               ha838bed_2  

$ PATH是:

/home/neurodad/miniconda2/envs/prod_keras/bin:/home/neurodad/miniconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda/bin:/usr/local/cuda/bin:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin

这是完整的文件夹结构,其中包含sphinx-quickstart创建的所有文件以及经过修改的conf.py作为zip文件: https://www.dropbox.com/s/f4bvtlu8xvl7eaj/sphinx_mcve.zip?dl=0

1 个答案:

答案 0 :(得分:0)

问题确实根源于Conda环境。 如果我停用Conda env并将所有必需的路径添加到PYTHONPATH,则狮身人面像程序可以正常工作。

我想我会朝那个方向搜索网。 感谢您的建议和帮助。