[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

org/matlab the python kernel and a problem (python 2 vs 3)

From: Uwe Brauer
Subject: org/matlab the python kernel and a problem (python 2 vs 3)
Date: Thu, 12 Dec 2019 16:16:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)


I am on Ubuntu 16.05 running either python 2.7 or 3.5.
I had matlab 2018b installed, and used the python engine to run matlab
commands from org file in a fast way.

I did, after installing the corresponding python3 modules, in the matlab
installation directory 

sudo -H python3 setup.py install 

I started the engine via 
in the python prompt:

import matlab.engine
eng = matlab.engine.start_matlab()

And for org I used 

  (add-to-list 'org-src-lang-modes '("matlab" . matlab))
  (setq python-shell-interpreter "python3")
  ;; set default headers for convenience
  (setq org-babel-default-header-args:matlab
        '((:results . "output replace")
          (:session . "matlab")
          (:kernel . "matlab")
          (:exports . "code")
          (:cache .   "no")
          (:noweb . "no")
          (:hlines . "no")
          (:tangle . "no")))
  (defalias 'org-babel-execute:matlab 'org-babel-execute:ipython)
  (defalias 'org-babel-prep-session:matlab 'org-babel-prep-session:ipython)
  (defalias 'org-babel-matlab-initiate-session 

Worked like charm

However I had to upgrade to 2019b
then the installation via python 3.5 failed

OSError: MATLAB Engine for Python supports Python version 2.7, 3.6, and 3.7, 
but your version of Python is 3.5

So I used 2.7 and changed the org setting accordingly.

However when I tried to execute matlab code, emacs run forever and
nothing happened.

Did anybody got this to work with python2.7?


Uwe Brauer  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]