已解决.
ob-mathematica.el
老不老? 老. 能不能用? 能用!
上面这个答案的配置是 linux 的, 若用 macOS, 我自己鼓捣出来能用的如下:
(unless (package-installed-p 'ob-mathematica)
(package-vc-install
'(ob-mathematica
:url "https://github.com/tririver/ob-mathematica/")))
(use-package ob-mathematica
:init
(setq org-babel-mathematica-command "/Applications/Mathematica.app/Contents/MacOS/WolframKernel -script")
然后貌似还要用 wolfram-mode 才能加 font-lock:
(use-package wolfram-mode
:config
(org-babel-do-load-languages ;; load mathematica from contrib
'org-babel-load-languages
(append org-babel-load-languages
'((mathematica . t))))
(add-to-list 'org-src-lang-modes '("mathematica" . "wolfram")) ;; font-locking
)
最终运行效果如下, 貌似有点一言难尽…:
最后还可以直接用 python 运行 Wolfram language …
没啥好的方案。。。。前一段时间用,查了下。相关的包都很老。
ob-mathematica works for me:
(use-package ob-mathematica
:straight t
:init
(setq org-babel-mathematica-command "wolfram -script"))
1 个赞
决定曲线救国, 用 python 运行 Wolfram language, 貌似装个 mathematica 就行了, 不用额外配置. 但是代码块必须用设置个 :session
, 否则不 work, 不知道为啥.
https://reference.wolfram.com/language/WolframClientForPython/
#+begin_src python :results output :session
from wolframclient.evaluation import WolframLanguageSession
from wolframclient.language import wl, wlexpr
session = WolframLanguageSession()
a = session.evaluate(
wlexpr('Quantity[1, "gram"]*Quantity[1, "SpeedOfLight"]^2//UnitConvert[#,"ton TNT"]&//N'))
print(a)
#+end_src
#+RESULTS:
: Quantity[21480.764310153383, 'TonsOfTNT']
谢谢, 请问有可能在 org mode 里用 Wolfram language 作图吗?
#+begin_src mathematica :results file :file test.jpg
Export["test.jpg", Plot[Sin[x], {x, 0, 10}]]
#+end_src
P.S. See Using Mathematica with Orgmode :: Rohit Goswami — Reflections
1 个赞