emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem
@ 2021-11-12 14:02 Uwe Brauer
  0 siblings, 0 replies; only message in thread
From: Uwe Brauer @ 2021-11-12 14:02 UTC (permalink / raw)
  To: emacs-orgmode

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 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-12 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 14:02 babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem Uwe Brauer

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).