emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: what does (json-readtable-error 47) mean (python, jupyter, matlab)
Date: Wed, 02 Oct 2024 09:52:00 +0200	[thread overview]
Message-ID: <87msjnrlgf.fsf@mat.ucm.es> (raw)

[-- Attachment #1: Type: text/plain, Size: 3888 bytes --]


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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5684 bytes --]

             reply	other threads:[~2024-10-02  7:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02  7:52 Uwe Brauer [this message]
2024-10-02 12:14 ` [SOLVED] (was: what does (json-readtable-error 47) mean (python, jupyter, matlab)) Uwe Brauer via General discussions about Org-mode.

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=87msjnrlgf.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \
    /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
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

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