emacs-orgmode
[Top][All Lists]
Advanced

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

what does (json-readtable-error 47) mean (python, jupyter, matlab)


From: Uwe Brauer
Subject: what does (json-readtable-error 47) mean (python, jupyter, matlab)
Date: Wed, 02 Oct 2024 09:52:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi,

I am using ob-ipython (which is a bit outdated) and I already opened an
issue at https://github.com/gregsexton/ob-ipython/issues/226  

However if someone knows how to deal with the (json-readtable-error 47)
error type, I would appreciate it.

Uwe Brauer 



Here is the explanation.


I successfully used ob-ipython with org mode and matlab, with Ubuntu 16.04, 
python 3.5 and matlab 2019a, its python engine  (and emacs 29.0.5 
compiled from a commit which was a pre 29 release)


Now I had to upgrade to Ubuntu 24.04 with python 3.12 (and emacs 29.4,
I also tried out the same 29.0.50 version I used in Ubuntu 16.04)

When I repeated the steps I list below and run 

#+begin_src matlab 
x = [1, 2, 3, 4, 5];
fprintf('|%d', x)
#+end_src

I obtain 
#+begin_src 
Debugger entered--Lisp error: (json-readtable-error 47)
  signal(json-readtable-error (47))
  json-read()
  ob-ipython--collect-json()
  ob-ipython--execute-request("x = [1, 2, 3, 4, 5];\nfprintf('|%d', x)" 
"matlab")
  ob-ipython--execute-sync("x = [1, 2, 3, 4, 5];\nfprintf('|%d', x)" 
((:colname-names) (:rowname-names) (:result-params "output" "replace") 
(:result-type . output) (:results . "output replace") (:exports . "code") 
(:session . "matlab") (:kernel . "matlab") (:cache . "no") (:noweb . "no") 
(:hlines . "no") (:tangle . "no")))
  org-babel-execute:matlab("x = [1, 2, 3, 4, 5];\nfprintf('|%d', x)" 
((:colname-names) (:rowname-names) (:result-params "output" "replace") 
(:result-type . output) (:results . "output replace") (:exports . "code") 
(:session . "matlab") (:kernel . "matlab") (:cache . "no") (:noweb . "no") 
(:hlines . "no") (:tangle . "no")))
  org-babel-execute-src-block(nil ("matlab" "x = [1, 2, 3, 4, 
5];\nfprintf('|%d', x)" ((:colname-names) (:rowname-names) (:result-params 
"replace" "output") (:result-type . output) (:results . "replace output") 
(:exports . "code") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . 
"no") (:kernel . "matlab") (:session . "matlab")) "" nil 1371 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  call-interactively(org-ctrl-c-ctrl-c nil nil)
  command-execute(org-ctrl-c-ctrl-c)
#+end_src
any idea how to fix this?


Below the steps.

Steps

#+begin_src 
sudo dpkg --purge python3-ptyprocess
pip3 install --user --upgrade --force-reinstall --no-cache-dir jupyter
pip3 install --user --upgrade --force-reinstall --no-cache-dir pymatbridge
pip3 install --user --upgrade --force-reinstall --no-cache-dir matlab_kernel

python3 -m matlab_kernel.check 
#+end_src


#+begin_src 
cd *usr/local/MATLAB/R2024b/extern/engines/python*
sudo /usr/bin/python3 setup.py install
#+end_src


Then
#+begin_src 
/usr/bin/python3
in the python prompt:
import matlab.engine
eng = matlab.engine.start_matlab()
#+end_src
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)   ;don't prompt me to confirm everytime I 
want to evaluate a block
(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 "python3")
(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

 



-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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