【问题标题】:Org-mode babel python session does not produce resultsorg-mode babel python session 不产生结果
【发布时间】:2014-06-05 13:37:14
【问题描述】:

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

* 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 它可以按预期工作。

标签: python org-mode python-babel


【解决方案1】:

为会话命名,例如:

    #+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
    : 

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-04
      • 2023-03-06
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多