Python 我如何告诉斯芬克斯使用水蟒解释器
我创建了一个Python项目,它使用Anaconda作为Python解释器。该项目运行良好,但现在我试图使用Sphinx来记录它,我遇到了一个问题,它找不到加密库。有没有办法告诉Sphinx使用Anaconda Python解释器?还是列出依赖项的方法,以便可以找到所有依赖项 以下是运行Python 我如何告诉斯芬克斯使用水蟒解释器,python,anaconda,python-sphinx,Python,Anaconda,Python Sphinx,我创建了一个Python项目,它使用Anaconda作为Python解释器。该项目运行良好,但现在我试图使用Sphinx来记录它,我遇到了一个问题,它找不到加密库。有没有办法告诉Sphinx使用Anaconda Python解释器?还是列出依赖项的方法,以便可以找到所有依赖项 以下是运行makehtml命令时出现的错误: Running Sphinx v1.5.5 making output directory... loading pickled environment... not yet
makehtml
命令时出现的错误:
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.
因此,我需要从Path变量中删除对Python27的所有引用,删除PYTHONHOME环境变量,然后使用命令
make html SPHINXBUILD=C:\Anaconda2\Lib\site packages\Sphinx-1.5.4-py2.7.egg\Sphinx
我不熟悉Anaconda对虚拟环境和打包的处理。对于安装了所有项目包和Sphinx的Python虚拟环境,我不激活虚拟环境,而是使用make html SPHINXBUILD=/path/to/virtual_environment/bin/Sphinx build
调用Sphinx,文档构建成功。也许水蟒也有类似的东西?@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而不是Python27巨蟒。sphinx构建文件夹是否包含autodoc.py之类的脚本?
@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