我如何告诉Sphinx使用Anaconda口译员

时间:2017-05-03 14:33:18

标签: python anaconda python-sphinx

我创建了一个使用Anaconda作为python解释器的Python项目。该项目运行良好,但现在我正在尝试使用Sphinx来记录它,我遇到了一个无法找到Crypto库的问题。有没有办法让Sphinx使用Anaconda Python Interpreter?或者列出依赖关系的方法,以便可以找到它们?

以下是运行make html命令时出现的错误:

Running Sphinx v1.5.5
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 6 source files that are out of date
updating environment: 6 added, 0 changed, 0 removed
reading sources... [100%] modules

C:\Users\MyUser\MyProject\docs\source\http.rst:19: WARNING: autodoc: failed to import module u'h
ttp.security_mgr'; the following exception was raised:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\sphinx\ext\autodoc.py", line 551, in import_object
    __import__(self.modname)
  File "C:\Users\MyUser\MyProject\http\security_mgr.py", line 29, in <module>
    from Crypto.Cipher import AES
ImportError: No module named Crypto.Cipher
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] modules
generating indices... genindex py-modindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 1 warnings.

Build finished. The HTML pages are in build\html.

这是我的make文件:

@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
    set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=PythonSDK

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
    echo.
    echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
    echo.installed, then set the SPHINXBUILD environment variable to point
    echo.to the full path of the 'sphinx-build' executable. Alternatively you
    echo.may add the Sphinx directory to PATH.
    echo.
    echo.If you don't have Sphinx installed, grab it from
    echo.http://sphinx-doc.org/
    exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd

1 个答案:

答案 0 :(得分:0)

所以事实证明我需要从Path变量中删除对Python27的所有引用,删除PYTHONHOME环境变量,然后使用命令make html SPHINXBUILD=C:\Anaconda2\Lib\site-packages\Sphinx-1.5.4-py2.7.egg\sphinx