Skip to content
Back to home
Back to blog
Tutorial

Run Python on Android: On-Device, Offline, No Setup

Yes, you can run real Python on an Android phone — CPython 3.11 with the full standard library, executing on-device and fully offline. Here's how it works, what it can do, and where its limits are.

6 min
By Pelayo Naredo
Run Python on Android: On-Device, Offline, No Setup

Search "run Python on Android" and most answers send you down one of two roads: install a full terminal environment and compile things by hand, or paste your code into a website that runs it on someone else's server. The first is fiddly; the second stops working the moment you lose signal.

PocketCode takes a third road: it runs real Python, directly on your phone, with no connection required. Open a .py file, tap Run, and CPython executes on the device in your hand. This post explains exactly how that works, what you can build with it, and — just as importantly — where the honest limits are.

Real CPython, running on the device

This isn't a Python-like interpreter or a hosted sandbox. PocketCode bundles a complete CPython 3.11 and runs it on-device: the build is compiled to WebAssembly and executed by an embedded runtime inside the app. There's no remote server doing the work, and nothing to configure — install PocketCode and Python is simply there, online or off.

Because execution is local, two things follow that matter on a phone:

  • It works fully offline. On a plane, on the metro, on a dead-zone commute — your scripts still run, because the interpreter lives on your device, not on a server.
  • Your code stays on your device. Nothing is uploaded to a third-party runner to execute.

What you can actually run

You get the complete CPython 3.11 standard library — the batteries Python is famous for:

You want to…Use
Parse and generate JSONjson
Match and transform textre
Do math and statsmath, statistics, random
Work with dates and timedatetime, time
Structure datacollections, dataclasses, itertools
Read and write filespathlib, csv, io

Here's a script that uses nothing but the standard library — it runs exactly as-is:

import json, statistics

scores = [88, 92, 79, 95, 88, 73]
summary = {
    "count": len(scores),
    "mean": round(statistics.mean(scores), 1),
    "median": statistics.median(scores),
    "max": max(scores),
}
print(json.dumps(summary, indent=2))

Tap Run and the console prints:

{
  "count": 6,
  "mean": 85.8,
  "median": 88.0,
  "max": 95
}

That covers the vast majority of scripting, automation, algorithm practice, data munging, and learning-to-code work. If you're studying for interviews, following a Python course, prototyping a parser, or scripting a quick transformation on the go, it runs as-is.

The honest limits

We'd rather set expectations than have you hit a wall, so here's the straight version:

  • No pip, no external packages. You can't install third-party libraries at runtime. Anything that isn't in the standard library — including C-extension-backed packages like NumPy or pandas — won't import. This is a scripting and learning environment, not a data-science stack.
  • No internet from a script. The interpreter runs in a WebAssembly sandbox with networking disabled, so a script can't open a socket or fetch a URL (urllib/requests-style calls won't reach the network). It reads and writes your project's files and prints to the console — it just doesn't call out.
  • Standard-library Python only. If a tutorial's first line is pip install ..., that part won't apply here.
  • Interpreter-speed, not native speed. On-device execution is plenty fast for scripts and exercises, but heavy number-crunching will feel slower than a desktop CPython with native optimizations.

Within those lines, it's real Python with no asterisks.

The workflow: open, Run, read the output

Running a script is deliberately boring — which is the point:

  1. Open or create a .py file in the code editor.
  2. Tap Run. PocketCode routes the file to its on-device Python runner.
  3. Output streams into the console exactly like any other process — print(), tracebacks, exit codes and all.

You get the editor's full toolkit around it, too: LSP-backed autocomplete and inline diagnostics, on-device PEP-8 formatting, a programming symbol bar so : and [] aren't a scavenger hunt, and multi-cursor editing — all on the phone.

One note on scope: Python runs from the editor's Run button. If you ask the built-in AI assistant to execute a script for you, that path is being wired to the same on-device runner — for running code today, use Run in the editor.

Python is one of many

Python isn't a one-off. The same on-device execution model powers a dozen languages in PocketCode — so the phone that runs your Python script can also run a JavaScript file on a real bundled Node.js, a Ruby one-liner, or compile and run C with an on-device compiler, all without a server in the loop. Five languages are ready the moment you install (Python, JavaScript, C, Ruby, PHP); the rest arrive as optional packs. We cover the full lineup in a dedicated guide — for now, know that "can it run my language?" usually has a yes.

Can you run Python on Android? Quick answers

Can you run Python on Android? Yes. PocketCode runs a full CPython 3.11 interpreter directly on the phone — open a .py file, tap Run, and it executes on-device, no server involved.

Do you need Termux? No. The interpreter is built in — nothing to install or compile. It works the moment you open the app.

Does it run offline? Yes, completely. The interpreter lives on your device, so scripts run with no connection.

Is it real Python? Yes — real CPython 3.11 with the full standard library, not a look-alike.

Can you use pip / NumPy / pandas? No. You get the complete standard library, but there's no pip and no C-extension packages. It's a scripting and learning environment, not a data-science stack.

Can a script reach the internet? No — the interpreter runs in a sandbox with networking disabled.


A phone in your pocket is a genuinely capable Python machine — offline, private, and instant. Not for training a neural net, but absolutely for learning the language, practicing algorithms, and scripting real work while you're away from a desk.

PocketCode is heading to Google Play. Join the pre-registration to run Python on your own device.

The tool behind this article

Code Editor

Ready to try PocketCode?

Download the app and start coding from your mobile.