Cannot create Python venv or install packages inside new Docker Sandbox (PEP 668 / externally-managed-environment)

Hi everyone,

I’m running into issues with the new Docker Sandbox feature and Python environment management. I’m unable to install packages or create virtual environments inside the sandbox.

Here’s what I’m seeing.

:one: pip install fails with “externally-managed-environment”

agent@claude-sandbox-2026-02-11-185529:~/workspace$ python3 -m pip install --user uv
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz
...
hint: See PEP 668 for the detailed specification.

This looks like Debian/Ubuntu’s PEP 668 enforcement.


:two: Creating a venv fails (ensurepip missing)

agent@claude-sandbox-2026-02-11-185529:~/workspace$ python3 -m venv venv
The virtual environment was not created successfully because ensurepip is not available.

On Debian/Ubuntu systems, you need to install the python3.13-venv package.

:three: Installing python3.13-venv is not possible

Without sudo:

apt install python3.13-venv
Error: Could not open lock file /var/lib/dpkg/lock-frontend - Permission denied

With sudo:

sudo apt install python3.13-venv
Package python3.13-venv is not available
Error: Package 'python3.13-venv' has no installation candidate

:four: pyenv is not available

pyenv
bash: pyenv: command not found

Summary

Inside the Docker Sandbox:

  • pip install --user is blocked due to PEP 668
  • python3 -m venv fails because ensurepip is missing
  • apt install python3.13-venv is unavailable
  • Installing system packages is restricted
  • No pyenv available

This effectively prevents:

  • Creating isolated Python environments
  • Installing alternative Python versions
  • Installing project-specific dependencies

Questions

  1. Is the Docker Sandbox intentionally designed to prevent creating virtual environments?
  2. Is there a supported way to:
  • Install additional Python versions?
  • Create isolated environments?
  • Use tools like uv, pipx, or pyenv?
  1. Is the recommended approach to build a custom image instead of using the provided sandbox image?

Any clarification on the intended workflow for Python development inside Docker Sandbox would be greatly appreciated.

Thanks!

Have you tried sudo apt update before apt install? If the cache is not updated, apt will see no installable packages. It can happen on a new virtual machine as well, but more often in containers as the cache is usually deleted while building images right after a package was installed to make the image smaller

The sandbox was designed to isolate your AI agents which you can also ask to install packages. It would not stop you from doing that, especially not from creating a python virtual environment.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.