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)

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	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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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 \
    --subject='Re: babel+matlab+python2.7+matlab_kernel ipython jupyter matlab: problem' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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