joouha / euporie

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

AttributeError: 'NotebookApp' object has no attribute 'background_tasks' #44

Closed jessebot closed 1 year ago

jessebot commented 1 year ago

This is such a cool app! Thank you for this! :)

I tried to run it in iterm2 using Python 3.11.0 on macOS Ventura (13.0.1) after running:

python -m pip install --user euporie
euporie-notebook

And it launches, but when I do CTRL+n to create a new notebook, it unfortunately gives an error:

Screenshot 2022-12-01 at 08 31 10

I can't select the ? in that image, but I can select copy traceback, which doesn't do anything immediately, but if I hit CTRL+q, it prints the following traceback

2022-12-01 08:24:02 CRITICAL Uncaught exception     euporie.core.log.handle_exception:421
Traceback (most recent call last):
    File "/Users/friend/Library/Python/3.11/bin/euporie-notebook", line 8, in <module>
      sys.exit(main())
               ^^^^^^
    File "/Users/friend/Library/Python/3.11/lib/python/site-packages/euporie/notebook/__main__.py", line 8, in main
      __main__.main(__name__.split(".")[1])
    File "/Users/friend/Library/Python/3.11/lib/python/site-packages/euporie/core/__main__.py", line 10, in main
      return entry.load().launch()
             ^^^^^^^^^^^^^^^^^^^^^
    File "/Users/friend/Library/Python/3.11/lib/python/site-packages/euporie/core/app.py", line 534, in launch
      return cls().run()
             ^^^^^^^^^^^
   File "/Users/friend/Library/Python/3.11/lib/python/site-packages/prompt_toolkit/application/application.py",
  line 978, in run    return loop.run_until_complete(
             ^^^^^^^^^^^^^^^^^^^^^^^^
   File
  "/usr/local/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_event…
  , line 650, in run_until_complete    return future.result()
             ^^^^^^^^^^^^^^^
   File "/Users/friend/Library/Python/3.11/lib/python/site-packages/prompt_toolkit/application/application.py",
  line 891, in run_async    await self.cancel_and_wait_for_background_tasks()
   File "/Users/friend/Library/Python/3.11/lib/python/site-packages/euporie/core/app.py", line 832, in
  cancel_and_wait_for_background_tasks    for task in self.background_tasks:
                  ^^^^^^^^^^^^^^^^^^^^^
  AttributeError: 'NotebookApp' object has no attribute 'background_tasks'

I also tried uninstalling with pip and then reinstalling with pipx, but got the same error and traceback:

2022-12-01 08:40:32 CRITICAL Uncaught exception
euporie.core.log.handle_exception:421
Traceback (most recent call last):
              File "/Users/friend/.local/bin/euporie", line 8, in <module>
                sys.exit(main())
                         ^^^^^^
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/euporie…
            , line 10, in main    return entry.load().launch()
                       ^^^^^^^^^^^^^^^^^^^^^
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/euporie…
            , line 32, in launch    main(app)
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/euporie…
            , line 10, in main    return entry.load().launch()
                       ^^^^^^^^^^^^^^^^^^^^^
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/euporie…
            , line 534, in launch    return cls().run()
                       ^^^^^^^^^^^
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/prompt_…
            , line 978, in run    return loop.run_until_complete(
                       ^^^^^^^^^^^^^^^^^^^^^^^^
             File
            "/usr/local/Cellar/python@3.11/3.11.0/Frameworks/Python.framework/Versions/3.…
            , line 650, in run_until_complete    return future.result()
                       ^^^^^^^^^^^^^^^
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/prompt_…
            , line 891, in run_async    await self.cancel_and_wait_for_background_tasks()
             File
            "/Users/friend/.local/pipx/venvs/euporie/lib/python3.11/site-packages/euporie…
            , line 832, in cancel_and_wait_for_background_tasks    for task in self.
            background_tasks:                ^^^^^^^^^^^^^^^^^^^^^
            AttributeError: 'NotebookApp' object has no attribute 'background_tasks'
jessebot commented 1 year ago

This also happens when installing Debian Bookworm with , however, at a later stage. It happens after I've run the following :

Then it doesn't do anything, so I quit, and then there's the same error that was present on macOS, but in Debian this time:

2022-12-01 09:08:14 CRITICAL Uncaught exception              euporie.core.log.handle_exception:421                             Traceback (most recent call last):
                               File "/home/friend/.local/bin/euporie", line 8, in <module>
                                 sys.exit(main())
                                          ^^^^^^
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/euporie/core/__mai…
                             , line 10, in main    return entry.load().launch()
                                        ^^^^^^^^^^^^^^^^^^^^^
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/euporie/core/launc…
                             , line 32, in launch    main(app)
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/euporie/core/__mai…
                             , line 10, in main    return entry.load().launch()
                                        ^^^^^^^^^^^^^^^^^^^^^
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/euporie/core/app.p…
                             , line 534, in launch    return cls().run()
                                        ^^^^^^^^^^^
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/prompt_toolkit/app…
                             , line 978, in run    return loop.run_until_complete(
                                        ^^^^^^^^^^^^^^^^^^^^^^^^
                              File
                             "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/asyncio/b…
                             , line 650, in run_until_complete    return future.result()
                                        ^^^^^^^^^^^^^^^
                              File
                             "/home/friend/.local/lib/python3.11/site-packages/prompt_toolkit/app…
                             , line 891, in run_async    await self.
                             cancel_and_wait_for_background_tasks()  File
                             "/home/friend/.local/lib/python3.11/site-packages/euporie/core/app.p…
                             , line 832, in cancel_and_wait_for_background_tasks    for task in
                             self.background_tasks:                ^^^^^^^^^^^^^^^^^^^^^
                             AttributeError: 'NotebookApp' object has no attribute 'background_tas
                             ks'
joouha commented 1 year ago

Hello! I'm glad you like euporie

There seem to be three separate issues here:

  1. Kernel died before replying to kernel_info error

    This is probably because your ipykernel install is messed up somehow. You can usually fix this by re-installing ipykernel, then re-registering the kernel as follows:

    python -m ipykernel install --user 
  2. 'NotebookApp' object has no attribute 'background_tasks' error

    I just noticed this myself yesterday - it's due to a change in the latest version of prompt_toolkit (v3.0.33). I've pushed a fix (67f64f6eed16e9c471c24b261e9a0eabd604cbe2) and made a new release (v2.1.5), so if you upgrade euporie hopefully this will be fixed.

  3. GCC required to install euporie in Python 3.11

    The reason for this is that Python 3.11 was only released just over a month ago, and it takes time for package maintainers to build and release new wheels for packages with compiled components. This is why pip is having to compile some packages from source, and hence the need for GCC.

    I just tried installing euporie on Debian Bookworm with Python 3.11, and pip had to compile yarl from source, which required python3.11-dev and gcc to be installed. Once yarl releases wheels for 3.11, GCC should no longer be necessary. There is an issue for this here: https://github.com/aio-libs/yarl/issues/781

I hope this helps

jessebot commented 1 year ago

Thank you for your quick reply, I will give this a try asap! :)

jessebot commented 1 year ago

Very late responding but yes, with the latest version, and fixing my ipykernel for python3.11 (who knows what i did with that), we are good to go! Thank you for your help! :)