emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem
Date: Fri, 12 Nov 2021 15:02:49 +0100	[thread overview]
Message-ID: <87v90xbhfa.fsf@mat.ucm.es> (raw)


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.
Cd $MATLABROOT/extern/engines/python
sudo -H python3 setup.py install 
** Start the engine
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)

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)

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?


Uwe Brauer 

                 reply	other threads:[~2021-11-12 14:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v90xbhfa.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).