emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* what does (json-readtable-error 47) mean (python, jupyter, matlab)
@ 2024-10-02  7:52 Uwe Brauer
  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.
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Brauer @ 2024-10-02  7:52 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [SOLVED] (was: what does (json-readtable-error 47) mean (python, jupyter, matlab))
  2024-10-02  7:52 what does (json-readtable-error 47) mean (python, jupyter, matlab) Uwe Brauer
@ 2024-10-02 12:14 ` Uwe Brauer via General discussions about Org-mode.
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Brauer via General discussions about Org-mode. @ 2024-10-02 12:14 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:

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

A solution can be found at 
https://github.com/dinojr/ob-ipython/tree/master

The client.py ob-ipython ships needs to be modified for more recent
python versions.


-- 
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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-02 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02  7:52 what does (json-readtable-error 47) mean (python, jupyter, matlab) Uwe Brauer
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.

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