Skip to content

CodeBox: auto-install does not work — import of missing packages raises ModuleNotFoundError #233

@yingjunwu

Description

@yingjunwu

Description

The documentation claims CodeBox automatically detects and installs missing packages (code-execution.mdx Step 2, quickstart-python.mdx, core-concepts.mdx). In practice, this does not work — importing a package not present in python:slim raises ModuleNotFoundError.

Reproduction

import asyncio
import boxlite

async def main():
    async with boxlite.CodeBox() as codebox:
        result = await codebox.run("""
import requests
response = requests.get('https://api.github.com/zen')
print(response.text)
""")
        print(result)

asyncio.run(main())

Expected

CodeBox detects import requests, installs requests via pip, then re-runs the code.

Actual

ModuleNotFoundError: No module named 'requests'

Environment

  • boxlite 0.5.10
  • macOS Apple Silicon
  • Python 3.12

Notes

install_package("requests") works fine when called explicitly. The issue is specifically the auto-detection + auto-install feature.

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