我如何告诉狮身人面像使用Anaconda Interpreter

问题描述:

我已经创建了一个使用Anaconda作为python解释器的Python项目。该项目运行良好,但现在我试图使用Sphinx来记录它,我遇到了一个问题,它找不到Crypto库。有没有办法告诉Sphinx使用Anaconda Python解释器?还是一种列出依赖关系的方法,以便它们都可以找到?我如何告诉狮身人面像使用Anaconda 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 
+0

我不熟悉Anaconda处理虚拟环境和打包。对于我安装我所有项目的包和Sphinx的Python虚拟环境,我不会激活虚拟环境,并使用'make html SPHINXBUILD =/path/to/virtual_environment/bin/sphinx-build'调用Sphinx,并且成功构建文档。也许Anaconda有类似的东西? –

+0

@StevePiercy我不确定我是否指向正确的位置。我在错误中找到了Anaconda版本的路径,并尝试使用命令'make html SPHINXBUILD = C:\ Anaconda2 \ Lib \ site-packages \ Sphinx-1.5.4-py2.7.egg \ sphinx'和'make html SPHINXBUILD = C:\ Anaconda2 \ Lib \ site-packages \ Sphinx-1.5.4-py2.7.egg \ sphinx \ ext'但我仍然得到一个错误,它使用Python27而不是Anaconda。你的sphinx-build文件夹是否包含像autodoc.py这样的脚本? – jencoston

因此,原来我需要从消除对Python27所有引用Path变量,删除PYTHONHOME环境变量,然后使用命令make html SPHINXBUILD=C:\Anaconda2\Lib\site-packages\Sphinx-1.5.4-py2.7.egg\sphinx