Skip to content

IndexError: list index out of range #2

@namuan

Description

@namuan

Hi, Just trying to run the example in the README file and it fails due to the following error

Traceback (most recent call last):
  File "/Users/nnn/workspace/llm-playground/./local-code-execution.py", line 17, in <module>
    asyncio.run(main())
  File "/Users/nnn/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/nnn/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nnn/.local/share/uv/python/cpython-3.12.0-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/nnn/workspace/llm-playground/./local-code-execution.py", line 11, in main
    async with ExecutionContainer(tag="ghcr.io/gradion-ai/ipybox:minimal") as container:
  File "/Users/nnn/.cache/uv/archive-v0/25Fji6Z4DBcKe4b7hY7Wz/lib/python3.12/site-packages/ipybox/container.py", line 64, in __aenter__
    await self.run()
  File "/Users/nnn/.cache/uv/archive-v0/25Fji6Z4DBcKe4b7hY7Wz/lib/python3.12/site-packages/ipybox/container.py", line 100, in run
    self._container = await self._run()
                      ^^^^^^^^^^^^^^^^^
  File "/Users/nnn/.cache/uv/archive-v0/25Fji6Z4DBcKe4b7hY7Wz/lib/python3.12/site-packages/ipybox/container.py", line 125, in _run
    self._port = int(container_info["NetworkSettings"]["Ports"][f"{executor_port}/tcp"][0]["HostPort"])
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
Unclosed connector
connections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x1066489b0>, 662274.882378458)])']
connector: <aiohttp.connector.UnixConnector object at 0x1057f6060>

Code:

#!/usr/bin/env -S uv run --quiet --script
# /// script
# dependencies = [
#   "ipybox",
# ]
# ///
import asyncio
from ipybox import ExecutionClient, ExecutionContainer

async def main():
    async with ExecutionContainer(tag="ghcr.io/gradion-ai/ipybox:minimal") as container:
        async with ExecutionClient(port=container.port) as client:
            result = await client.execute("print('Hello, world!')")
            print(f"Output: {result.text}")

if __name__ == "__main__":
    asyncio.run(main())

Other details:

$ docker --version                                                                                          
Docker version 27.4.0, build bde2b89

MacOS

Version 15.1.1 (24B91)

Python

$ python3 --version
Python 3.11.11

Please let me know if you want me to provide any more information

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions