Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'start' #69

Open
kostrykin opened this issue Oct 24, 2022 · 1 comment
Open

AttributeError: 'NoneType' object has no attribute 'start' #69

kostrykin opened this issue Oct 24, 2022 · 1 comment

Comments

@kostrykin
Copy link

I have installed nbterm 0.0.13 using pip.

I have a notebook test.ipynb which consists of a single cell (1+1).

I am trying to run the notebook in batch mode using nbterm --run test.ipynb which gives the following error:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /private/tmp/test/env/lib/python3.9/site-packages/nbterm/nbterm.py:73 in main                    │
│                                                                                                  │
│   70 │   )                                                                                       │
│   71 │   if run:                                                                                 │
│   72 │   │   assert no_kernel is not True                                                        │
│ ❱ 73 │   │   asyncio.run(nb.run_all())                                                           │
│   74 │   │   if save_path is None:                                                               │
│   75 │   │   │   directory = notebook_path.parent                                                │
│   76 │   │   │   prefix = str(directory / f"{notebook_path.stem}_run")                           │
│                                                                                                  │
│ ╭───────────────────────────── locals ─────────────────────────────╮                             │
│ │    kernel_cwd = PosixPath('.')                                   │                             │
│ │            nb = <nbterm.notebook.Notebook object at 0x102216460> │                             │
│ │     no_kernel = None                                             │                             │
│ │ notebook_path = PosixPath('test.ipynb')                          │                             │
│ │        prefix = 'Untitled'                                       │                             │
│ │           run = True                                             │                             │
│ │     save_path = None                                             │                             │
│ │          test = None                                             │                             │
│ │       version = None                                             │                             │
│ ╰──────────────────────────────────────────────────────────────────╯                             │
│                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/kostrykin2021-m1/lib/python3.9/asyncio/runners.py:44  │
│ in run                                                                                           │
│                                                                                                  │
│   41 │   │   events.set_event_loop(loop)                                                         │
│   42 │   │   if debug is not None:                                                               │
│   43 │   │   │   loop.set_debug(debug)                                                           │
│ ❱ 44 │   │   return loop.run_until_complete(main)                                                │
│   45 │   finally:                                                                                │
│   46 │   │   try:                                                                                │
│   47 │   │   │   _cancel_all_tasks(loop)                                                         │
│                                                                                                  │
│ ╭──────────────────────────────── locals ────────────────────────────────╮                       │
│ │ debug = None                                                           │                       │
│ │  loop = <_UnixSelectorEventLoop running=False closed=True debug=False> │                       │
│ │  main = <coroutine object Notebook.run_all at 0x1021f6ac0>             │                       │
│ ╰────────────────────────────────────────────────────────────────────────╯                       │
│                                                                                                  │
│ /opt/homebrew/Caskroom/miniforge/base/envs/kostrykin2021-m1/lib/python3.9/asyncio/base_events.py │
│ :642 in run_until_complete                                                                       │
│                                                                                                  │
│    639 │   │   if not future.done():                                                             │
│    640 │   │   │   raise RuntimeError('Event loop stopped before Future completed.')             │
│    641 │   │                                                                                     │
│ ❱  642 │   │   return future.result()                                                            │
│    643 │                                                                                         │
│    644 │   def stop(self):                                                                       │
│    645 │   │   """Stop running the event loop.                                                   │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │   future = <Task finished name='Task-1' coro=<Notebook.run_all() done, defined at            │ │
│ │            /private/tmp/test/env/lib/python3.9/site-packages/nbterm/notebook.py:117>         │ │
│ │            exception=AttributeError("'NoneType' object has no attribute 'start'")>           │ │
│ │ new_task = True                                                                              │ │
│ │     self = <_UnixSelectorEventLoop running=False closed=True debug=False>                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /private/tmp/test/env/lib/python3.9/site-packages/nbterm/notebook.py:118 in run_all              │
│                                                                                                  │
│   115 │   │   await self.current_cell.run()                                                      │
│   116 │                                                                                          │
│   117 │   async def run_all(self):                                                               │
│ ❱ 118 │   │   await self.kd.start()                                                              │
│   119 │   │   for i in range(len(self.cells)):                                                   │
│   120 │   │   │   await self.run_cell(i)                                                         │
│   121                                                                                            │
│                                                                                                  │
│ ╭──────────────────────── locals ─────────────────────────╮                                      │
│ │ self = <nbterm.notebook.Notebook object at 0x102216460> │                                      │
│ ╰─────────────────────────────────────────────────────────╯                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'start'

Why isn't this working as expected and what does the error mean?

@davidbrochart
Copy link
Owner

Assuming the code you want to execute is written in Python, you need to install a Python kernel. You can e.g.:

pip install ipykernel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants