【发布时间】:2014-10-09 15:24:54
【问题描述】:
我写了一个很长的 IPython notebook,需要把它转换成 PDF 来分发。我已阅读 this thread,但该解决方案对我不起作用。
我尝试了以下方法:
如果我在浏览器中使用“打印”按钮,我将拥有所有 IPython 菜单 等显示,我不能接受。
如果我使用 IPython 菜单中的打印预览,则不会呈现任何 LaTeX 方程。它们仍然只是 LaTeX 代码。
如果我使用
ipython nbconvert --to latex --post pdf myfile.ipynb,我会得到FileNotFoundError。追溯如下:
[NbConvertApp] Using existing profile dir: 'C:\\Users\\blokeley\\.ipython\\profile_default'
[NbConvertApp] Converting notebook myfile.ipynb to latex
[NbConvertApp] Support files will be in myfile_files\
[NbConvertApp] Loaded template article.tplx
[NbConvertApp] Writing 72246 bytes to myfile.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running pdflatex 3 times: ['pdflatex', 'myfile.tex']
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\ipython-script.py", line 5, in <module>
sys.exit(start_ipython())
File "C:\Anaconda3\lib\site-packages\IPython\__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Anaconda3\lib\site-packages\IPython\config\application.py", line 564,
launch_instance
app.start()
File "C:\Anaconda3\lib\site-packages\IPython\terminal\ipapp.py", line 367, in start
return self.subapp.start()
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\nbconvertapp.py",
line 268, in start
self.convert_notebooks()
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\nbconvertapp.py",
line 311, in convert_notebooks
self.postprocessor(write_resultes)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\base.py",
line 28, in __call__
self.postprocess(input)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 140, in postprocess
cont = self.run_latex(filename)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 104, in run_latex
self.latex_count, log_error)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 84, in run_command
p = subprocess.Popen(command, stdout=stdout, stdin=null)
File "C:\Anaconda3\lib\subprocess.py", line 858, in __init__
restore_signals, start_new_session)
File "C:\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
c.Application.verbose_crash=True
我在 Windows 7 Professional 上使用 Python 3.4 64 位 Anaconda 的最新更新。
【问题讨论】:
-
没有。我在 Windows 上。 nbconvert 应该支持在没有安装 LaTeX 的情况下创建 PDF,所以这无关紧要。最重要的是,安装 LaTeX 不会很麻烦 - 它不需要 Cygwin 和所有这些吗?我曾希望我们可以使用 IPython 来代替 MATLAB,但如果它需要 Cygwin 和各种其他东西,我不会说服我的同事使用 IPython。
-
第 2 点:将 IPython 更新到 2.3 我们几乎就是为此而匆忙发布 IPython 2.3。
-
不,nbconvert 不支持没有乳胶的 pdf 创建,如果你能指出你在哪里读到这样的东西,我们可以尝试修复它。可能有一种方法是 .ipynb -> .rst 然后是 rst2pdf 但它还没有实现。
-
我安装了 ipython 2.3,现在至少 nbconvert 可以用数学转换为 html,这对我来说已经足够了。谢谢。我也会检查 Ffisegydd 生成的 PDF。
标签: python-3.x pdf-generation ipython ipython-notebook