jupyter / jupyter_console

Jupyter Terminal Console
http://jupyter-console.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
247 stars 146 forks source link

TypeError: object int can't be used in 'await' expression when ZMQTerminalInteractiveShell.include_other_output = True #275

Closed Praful closed 1 year ago

Praful commented 1 year ago

This may be related to https://github.com/jupyter/jupyter_console/issues/247.

If I create a minimalist jupyter_console_config.py with just these lines:

  c = get_config()  #noqa
  c.ZMQTerminalInteractiveShell.include_other_output = True

The following error occurs when I run jupyter_console:

Task exception was never retrieved
future: <Task finished name='Task-7' coro=<ZMQTerminalInteractiveShell.handle_external_iopub() done, defined at /home/praful/.pyenv/versions/3.11.1/lib/python3.11/site-packages/jupyter_console/ptshell.py:839> exception=TypeError("object int can't be used in 'await' expression")>
Traceback (most recent call last):
  File "/home/praful/.pyenv/versions/3.11.1/lib/python3.11/site-packages/jupyter_console/ptshell.py", line 842, in handle_external_iopub
    poll_result = await self.client.iopub_channel.socket.poll(500)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object int can't be used in 'await' expression
Shutting down kernel

This setting is required to use the jupyter-vim plugin.

I have done the same in jupyter_qtconsole_config.py and all is fine. For now, I'm running jupyter qtconsole.

The output of jupyter console --show-config is:

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Jupyter console 6.4.4

Python 3.11.1 (main, Feb  4 2023, 16:51:41) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.
Loaded config files:
  /home/praful/.jupyter/jupyter_console_config.py

ZMQTerminalInteractiveShell
  .include_other_output = True

Here is my system info:

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description:    Linux Mint 21.1
Release:    21.1
Codename:   vera

❯ uname -r
5.15.0-58-generic
jcrespy commented 1 year ago

Hey there. Commenting because I've got the exact same problem. Note that my install is older, and everything used to work just fine (i don't use jupyter very often so I can't say when it all started not working. A few tests I did : I have a 3.7 python interpreter (created with pyenv). I tried creating two venv, one on 3.7, one on the latest version on my system. Jupyter console runs fine on 3.7 interpreter, but the issue is there on 3.10 venv. Here is my test :

(test) julien@archdesktop[.venv](master) > python --version
Python 3.7.16
(test) julien@archdesktop[.venv](master) > jupyter console --show-config | grep output
  .include_other_output = True
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.
(test) julien@archdesktop[.venv](master) > jupyter console
Jupyter console 6.5.1

Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: quit()
Shutting down kernel
(test) julien@archdesktop[.venv](master) > which jupyter
/home/julien/.venv/test/bin/jupyter

(test) julien@archdesktop[.venv](master) > source test2/bin/activate
(test2) julien@archdesktop[.venv](master) > python --version
Python 3.10.9
(test2) julien@archdesktop[.venv](master) > jupyter console --show-config | grep output
  .include_other_output = True
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.
(test2) julien@archdesktop[.venv](master) > jupyter console
Jupyter console 6.5.1

Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 
Task exception was never retrieved
future: <Task finished name='Task-7' coro=<ZMQTerminalInteractiveShell.handle_external_iopub() done, defined at /home/julien/.venv/test2/lib/python3.10/site-packages/jupyter_console/ptshell.py:839> exception=TypeError("object int can't be used in 'await' expression")>
Traceback (most recent call last):
  File "/home/julien/.venv/test2/lib/python3.10/site-packages/jupyter_console/ptshell.py", line 842, in handle_external_iopub
    poll_result = await self.client.iopub_channel.socket.poll(500)
TypeError: object int can\'t be used in 'await' expression
Shutting down kernel
(test2) julien@archdesktop[.venv](master) > which jupyter
/home/julien/.venv/test2/bin/jupyter

Same as OP, qtconsole is working fine in both instances. Since I had a problem before with conflicts between pip installed packages and pacman installed packages, I also checked that I didn't have any conflicted version of packages. I have the habit of installing anything through pacman on archlinux, nothing comes from pip when I'm not in a venv. I did check, there were a few packages I had installed from pip - (listed with pip list -v) that had nothing to do with this, but I uninstalled them anyways : nothing changed).

zcysxy commented 1 year ago

Same problem and use case as OP. And the problem appears after an upgrade.

overfl0 commented 1 year ago

I have the same problem when launching from the commandline:

jupyter console --existing --ZMQTerminalInteractiveShell.include_other_output=true

The issue started happening in jupyter-client==8.0.0a0. If you downgrade to jupyter-client==7.4.9 everything starts to work again.

jcrespy commented 1 year ago

Don't know if this is just me, but this did not fully resolve the issue. With the new version, jupyter-console is not automatically exiting with the same error anymore. Instead, once the console is fully loaded and the expected TUI appears, the terminal completely freezes, I can't type any command, can't exit with ctrl+d and have to hard kill the whole terminal. This only happens with the aforementioned option

  c.ZMQTerminalInteractiveShell.include_other_output = True
blink1073 commented 1 year ago

Reopening, but it may be a bit before I can investigate.

jcrespy commented 1 year ago

Of course. Thanks for your help and attention, and when you're ready please ask if you need any help (I'm not skilled enough to debug this, but I can provide logs and other useful informations if need be). @Praful , @zcysxy , @overfl0 , before any dev spends time on this, maybe you could confirm if this issue is resolved on your side (it might be something wrong on my computer) ?

zcysxy commented 1 year ago

Can confirm in the newest version, the program freezes instead of throwing an error.

Praful commented 1 year ago

I've just updated to 6.6.2. The bad news is that, once started, the console is frozen at the In [1]: prompt as @jcrespy describes above. However, I can now connect to it from vim and send commands. We're halfway there :)

Thanks @blink1073 for looking at this issue.