emacs-orgmode
[Top][All Lists]
Advanced

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

babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem


From: Uwe Brauer
Subject: babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem
Date: Fri, 12 Nov 2021 15:02:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hi 

I am on ubuntu 16.04 with python 3.5 and 2.7 in the past I have used
successfully the matlab python kernel for 3.5

Using more or less this:
sudo apt-get install python3-setuptools
sudo -H python3 -m pip install jupyter
sudo apt-get remove python3-pexpect
sudo -H python3 -m pip install pexpect
sudo -H python3 -m pip install matlab_kernel
** Install the python API for matlab.
MATLABROOT=/usr/local/MATLAB/R2016b
Cd $MATLABROOT/extern/engines/python
sudo -H python3 setup.py install 
** Start the engine
Run
/usr/bin/python3
in the python prompt:
import matlab.engine
eng = matlab.engine.start_matlab()
the eng command needs some time to run. 


When finished run now 




#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)   
;;; display/update images in the buffer after I evaluate
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)
    
(add-to-list 'org-src-lang-modes '("matlab" . matlab))
(setq python-shell-interpreter "/usr/bin/python3")
;(setq python-shell-interpreter "/usr/bin/python2.7")
;; 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 
'org-babel-ipython-initiate-session)
#+END_SRC

However I am forced to use matlab 2019b, which is not longer compatible
with python 3.5, but according to their documentation with 2.7, so I
repeated the steps above using python-2.7 instead of 3.5

And of course
;(setq python-shell-interpreter "/usr/bin/python3")
(setq python-shell-interpreter "/usr/bin/python2.7")

But when I try to execute in an org file 

#+begin_src matlab :results output latex :exports results  :eval never-export 
:wrap latex
x = [1, 2, 3, 4, 5];
fprintf('|%d', x)
#+end_src


Emacs shows me that is he is working and working and finally I have to
interrupt the process, I also don't see any error stack.

Anybody has successfully used the above configuration with python 2.7?

Thanks

Uwe Brauer 




reply via email to

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