1

最近从 R 切换到 Python,我正在探索 Pweave 作为 Sweave 的替代品。示例文件(http://mpastell.com/pweave/examples/index.html)看起来很棒,所以我开始在这些文件上进行构建。使用命令

pweave -f tex FIR_design_verb.texw

从终端生成一个 .tex 文件,然后可以将其转换为包含数字的 pdf。

从 python 解释器(在我的情况下为 spyder)尝试相同的操作

import pweave pweave.weave('FIR_design_verb.texw', doctype = "tex")

不会产生相同的结果,数字不存在。生成的tex文件有

\begin{figure}[htpb] \center \caption{Test!} \label{fig:None} \end{figure}

缺少 \includegraphics{} 并创建了图形文件夹但为空。我是否缺少 pweave.weave() 中的参数?

Ps:作为一种解决方法,以下代码有效:

import subprocess cmd = ['pweave', '-f', 'tex', 'pweave_test.texw'] proc = subprocess.Popen(cmd) proc.communicate()

4

1 回答 1

1

我认为问题在于 Spyder 在 Pweave 之前导入了 ˋmatplotlibˋ,因此没有捕获这些数字。如果您运行“普通”python 解释器,您的代码应该可以工作。

于 2017-08-19T08:26:06.240 回答