org-mode babel python session 不产生结果 | 珊瑚贝

Org-mode babel python session does not produce results


我正在尝试使用 org-mode 和 babel 编写代码测试用例,但无法通过第一步:

1
2
3
4
5
6
7
8
9
10
11
12
13
* Running code example

Set up some variables
#+begin_src python :results output :session
x=1
#+end_src

Use some variables (in the end I‘ll have more useful
explanatory text between the code blocks).
#+begin_src python :exports both :results output :session
print”Hi”, x
#+end_src

从第二个块开始按顺序在块上击中 C-c 失败
没有定义 x。

导出文件(如果重要,导出为 PDF)似乎执行了所有
代码块,但没有构造第二个块的 RESULTS
并插入缓冲区。

如何修改代码块上的开关,以使所有内容
在会话中执行,结果嵌入到
组织缓冲区?

org-version=7.9.3f

  • 我没有 Python,所以我不能尝试。但是我看不出它为什么不起作用的明显原因,只要它在会话中运行。难道您不必在会话参数后添加名称,也许?
  • 尝试添加会话名称——同样的问题。
  • 对我来说,使用 org-mode v8.2.10 它可以按预期工作。


为会话命名,例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    #+name: session_init
    #+BEGIN_SRC python :results output :session example
    str=‘Hello, World’
    #+END_SRC

    #+RESULTS: session_init
    :
    : str=‘Hello World’
    : >>> >>> >>>
    :

    #+BEGIN_SRC python :results output :session example
    print str
    #+END_SRC

    #+RESULTS:
    : print str
    : Hello, World
    :


它适用于较新的组织模式(例如 8.2.10); org 8.0 发生了重大变化,因此最好的方法是升级您的 org-mode。


来源:https://www.codenong.com/24061744/

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?