joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.55k stars 36 forks source link

StdinNotImplementedError: raw_input was called, but this frontend does not support input requests. #11

Closed yingzhu146 closed 2 years ago

yingzhu146 commented 3 years ago

I just tried using %debug, however encountering the following

│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/site-packages/IPython/core/ultratb │   
│ .py:1266 in debugger                                                                      │   
│                                                                                           │   
│   1263 │   │   │   │   if etb and etb.tb_next:                                            │   
│   1264 │   │   │   │   │   etb = etb.tb_next                                              │   
│   1265 │   │   │   │   self.pdb.botframe = etb.tb_frame                                   │   
│ ❱ 1266 │   │   │   │   self.pdb.interaction(None, etb)                                    │   
│   1267 │   │                                                                              │   
│   1268 │   │   if hasattr(self, 'tb'):                                                    │   
│   1269 │   │   │   del self.tb                                                            │   
│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/site-packages/IPython/core/debugge │   
│ r.py:305 in interaction                                                                   │   
│                                                                                           │   
│   302 │                                                                                   │   
│   303 │   def interaction(self, frame, traceback):                                        │   
│   304 │   │   try:                                                                        │   
│ ❱ 305 │   │   │   OldPdb.interaction(self, frame, traceback)                              │   
│   306 │   │   except KeyboardInterrupt:                                                   │   
│   307 │   │   │   self.stdout.write("\n" + self.shell.get_exception_only())               │   
│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/pdb.py:357 in interaction          │   
│                                                                                           │   
│    354 │   │   │   self.forget()                                                          │   
│    355 │   │   │   return                                                                 │   
│    356 │   │   self.print_stack_entry(self.stack[self.curindex])                          │   
│ ❱  357 │   │   self._cmdloop()                                                            │   
│    358 │   │   self.forget()                                                              │   
│    359 │                                                                                  │   
│    360 │   def displayhook(self, obj):                                                    │   
│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/pdb.py:322 in _cmdloop             │   
│                                                                                           │   
│    319 │   │   │   │   # keyboard interrupts allow for an easy way to cancel              │   
│    320 │   │   │   │   # the current command, so allow them during interactive input      │   
│    321 │   │   │   │   self.allow_kbdint = True                                           │   
│ ❱  322 │   │   │   │   self.cmdloop()                                                     │   
│    323 │   │   │   │   self.allow_kbdint = False                                          │   
│    324 │   │   │   │   break                                                              │   
│    325 │   │   │   except KeyboardInterrupt:                                              │   
│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/cmd.py:126 in cmdloop              │   
│                                                                                           │   
│   123 │   │   │   │   else:                                                               │   
│   124 │   │   │   │   │   if self.use_rawinput:                                           │   
│   125 │   │   │   │   │   │   try:                                                        │   
│ ❱ 126 │   │   │   │   │   │   │   line = input(self.prompt)                               │   
│   127 │   │   │   │   │   │   except EOFError:                                            │   
│   128 │   │   │   │   │   │   │   line = 'EOF'                                            │   
│   129 │   │   │   │   │   else:                                                           │   
│                                                                                           │   
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/site-packages/ipykernel/kernelbase │   
│ .py:845 in raw_input                                                                      │   
│                                                                                           │   
│   842 │   │   StdinNotImplementedError if active frontend doesn't support stdin.          │   
│   843 │   │   """                                                                         │   
│   844 │   │   if not self._allow_stdin:                                                   │   
│ ❱ 845 │   │   │   raise StdinNotImplementedError(                                         │   
│   846 │   │   │   │   "raw_input was called, but this frontend does not support input req │   
│   847 │   │   │   )                                                                       │   
│   848 │   │   return self._input_request(str(prompt),                                     │   
╰───────────────────────────────────────────────────────────────────────────────────────────╯   
StdinNotImplementedError: raw_input was called, but this frontend does not support input        
requests.                                                                                       

For what it's worth, I tried to debug an issue with Kitty rendering


╭──────────────────────────── Traceback (most recent call last) ────────────────────────────╮ 
│ <ipython-input-5-1eb00ff78cf2>:1 in <module>                                              │ 
│                                                                                           │ 
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/site-packages/matplotlib/pyplot.py │ 
│ :353 in show                                                                              │ 
│                                                                                           │ 
│    350 │                                                                                  │ 
│    351 │   """                                                                            │ 
│    352 │   _warn_if_gui_out_of_main_thread()                                              │ 
│ ❱  353 │   return _backend_mod.show(*args, **kwargs)                                      │ 
│    354                                                                                    │ 
│    355                                                                                    │ 
│    356 def isinteractive():                                                               │ 
│                                                                                           │ 
│ /Users/yingzhu_/matplotlib-backend-kitty/__init__.py:79 in show                           │ 
│                                                                                           │ 
│   76 │   │   │   Gcf.destroy(manager)                                                     │ 
│   77 │                                                                                    │ 
│   78 │   def show(*args, **kwargs):                                                       │ 
│ ❱ 79 │   │   _Backend.show(*args, **kwargs)                                               │ 
│   80 │   │   Gcf.destroy_all()                                                            │ 
│   81 │                                                                                    │ 
│   82 │   trigger_manager_draw = _trigger_manager_draw                                     │ 
│                                                                                           │ 
│ /Users/yingzhu_/miniconda3/envs/python38/lib/python3.8/site-packages/matplotlib/backend_b │ 
│ ases.py:3524 in show                                                                      │ 
│                                                                                           │ 
│   3521 │   │   │   return                                                                 │ 
│   3522 │   │   for manager in managers:                                                   │ 
│   3523 │   │   │   try:                                                                   │ 
│ ❱ 3524 │   │   │   │   manager.show()  # Emits a warning for non-interactive backend.     │ 
│   3525 │   │   │   except NonGuiException as exc:                                         │ 
│   3526 │   │   │   │   cbook._warn_external(str(exc))                                     │ 
│   3527 │   │   if cls.mainloop is None:                                                   │ 
│                                                                                           │ 
│ /Users/yingzhu_/matplotlib-backend-kitty/__init__.py:47 in show                           │ 
│                                                                                           │ 
│   44 │   │   # gather terminal dimensions                                                 │ 
│   45 │   │   rows = int(tput("lines"))                                                    │ 
│   46 │   │   px = icat("--print-window-size")                                             │ 
│ ❱ 47 │   │   px = list(map(int, px.split("x")))                                           │ 
│   48 │   │                                                                                │ 
│   49 │   │   # account for post-display prompt scrolling                                  │ 
│   50 │   │   # 3 line shift for [\n, <matplotlib.axes…, >>>] after the figure             │ 
╰───────────────────────────────────────────────────────────────────────────────────────────╯ 
ValueError: invalid literal for int() with base 10: ''                                        
joouha commented 3 years ago

Hi,

I'm afraid euporie does not support sending user input to the kernel yet, so anything which requires user input (e.g. input, getpass, etc.) will not work. It shouldn't be too complicated to implement, so I'm happy to take this as a feature request.

For kitty image support - I haven't tested euporie with matplotlib-backend-kitty, but I wouldn't expect it to work without breaking the display. I'm not sure that your second trace-log is necessarily related to euporie.

If you want to use kitty graphics with euporie, you'll need to use the matplotlib's inline backend with PNG images, then euporie will render them using the kitty graphics protocol (if you are in a terminal which supports kitty graphics).

yingzhu146 commented 3 years ago

Perfect thanks a lot for the quick reply - this is helpful I was somehow assuming I had to use the matplotlib backend for it to work like in ipython. I'll try with inline.

Yes debugging would be crucial for me, especially given that a full featured notebook debugger just landed in the jupyter lab ipython kernel

joouha commented 2 years ago

Support for user input has been added and will be included in the next release

Closed by b5f460d46f5060b91fa4db1bcd3edb9738e44a08