Skip to content

Python quickstart CodeBox demo can appear to do nothing in clean env #439

@MarkovWangRR

Description

@MarkovWangRR

Summary

The Python quickstart codebox.py example can look like a silent no-op for first-time users in a clean environment.

Reproduction

Using the current quickstart snippet:

import asyncio
import boxlite

async def main():
    code = """
import requests
response = requests.get('https://api.github.com/zen')
print(response.text)
"""

    async with boxlite.CodeBox() as codebox:
        result = await codebox.run(code)
        print(result)

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

In a fresh python:slim runtime, this often returns empty output.

Why it happens

  • The snippet imports requests but does not install it first.
  • In fresh environments, requests is commonly missing (ModuleNotFoundError).
  • CodeBox.run() returns stdout only, so errors in stderr are not visible from print(result).

User impact

For newcomers following the official quickstart, this feels like a broken first-run experience (no output, no obvious error).

Proposed fix

Update quickstart snippet to install dependency explicitly before running code:

async with boxlite.CodeBox() as codebox:
    await codebox.install_package("requests")
    result = await codebox.run(code)
    print(result)

Optionally, document that run() returns stdout only and that stderr is available via exec() when debugging failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions