# How does the AI run Python on my phone?

> Cube Agent 2.4.1 Release (Build 2004105) User Guide.
> Category: Models & AI. Content baseline: 2026-12-05.
> Web page: https://cubeagent.app/en/docs/python_runtime/

## Overview

Python 3.12 is installed with the app. With **Code Workbench** enabled, the AI can use built-in or compatible libraries directly on your phone to process spreadsheets, analyze data, batch-process files, or generate Word, PowerPoint, and PDF documents. Scripts that depend on desktop software such as LibreOffice require an appropriate external environment.

- Comes pre-installed with common libraries including `pandas`, `numpy`, `openpyxl`, `matplotlib` (with CJK fonts configured), `Pillow`, and `lxml`.
- Document libraries such as `python-docx`, `python-pptx`, and `pypdf` are pre-bundled; other compatible pure-Python libraries can be installed online on first use and are kept afterward.
- Variables and computed data persist within the same conversation so you can build on them in follow-up turns.
- Command lines written in skill instructions (such as `python scripts/x.py` or `pip install`) run in the app's simulated Bash environment.
- MCP services can use `uvx`, `pipx run`, `python -m`, or `npx -y <package>@<version>` launch commands to start inside the built-in runtime.

## How to use

1. In the input bar, go to **Tools → Choose Tools** and enable **Code Workbench** (already included in the recommended set).
2. Bring the files you want processed into the chat: reference them with **@** or import them in **Conversation files**. Putting spreadsheets and data files in the workspace for Python to process saves far more context than sending entire raw files to the AI.
3. Simply describe your goal—for example, "Calculate the average score per department in this spreadsheet and plot a bar chart," or "Crop all 20 of these images to 1:1."
4. Code cards in replies show what each code block did and how long it took; expand a card to inspect the code and output. Generated files appear in the **Generated files** card where you can preview, save, or share them; charts saved to `outputs/` can also be displayed inline in the reply body.
5. Go to **Settings → Connections & advanced → Runtimes** to check Python and Node.js versions, view installed packages, configure default pip / npm mirrors, and clear the npm cache. Chinese-locale setups default to Mainland China mirrors, and you can switch to the official registries or a custom mirror URL at any time. The built-in runtime includes memory protection that automatically interrupts oversized computations and reclaims memory to prevent unexpected app exits.

## Best practices

- When you need exact calculations, statistics, or batch processing, explicitly tell the AI to "calculate this with Python"—the results are far more reliable than having the model estimate in text.
- To use Skill Market skills for PDF, Excel, Word, PowerPoint, poster design, animated GIFs, and more, install them and enable them on your assistant, or specify one in the input bar with **/**. Skill details list detected commands and packages.
- For tasks requiring LibreOffice or compiled native Python packages, switch to pure-Python libraries instead. For MCP services requiring Docker, native Node extensions, or system subprocesses, connect to a remote server URL.
- First-time automatic package installation requires an internet connection and may be slower on weak networks; if installation fails, the AI sees the error reason and switches to an alternative approach.
