py2droid
py2droid copied to clipboard
Magisk module to install Python 3 on Android.
Py2Droid
A Magisk module to install Python 3 on Android, including the standard library (STDLIB).
Installation
- Download the latest ZIP for your device's architecture from the Releases page.
- Open Magisk Manager and navigate to Modules.
- Tap Install from storage and choose the downloaded ZIP file.
- Wait for the installation to complete.
- Reboot your device.
Build Process
The build process is automated through scripts/build.py. Build parameters can be customized in build.toml.
To build from source:
-
Follow the prerequisites from cpython/Android/README.md
-
Create and activate a Python virtual environment:
python -m venv .venv . .venv/bin/activate -
Install required dependencies:
pip install -r scripts/requirements.txt -
Run the build script:
python scripts/build.py
After building, you can find the generated modules in the dist/ directory.
The script handles downloading Python source, cross-compilation for Android, and packaging the Magisk module.
Usage
Python
Access Python from any terminal with:
su -c python3
Installing Pip
Install pip, the Python package manager, using the following command:
su -c python3 -m ensurepip
Once installed, you can access pip using:
su -c python3 -m pip
This gives you access to pip for installing and managing Python packages.
Updating the Module's Bin Directory
When you install executables (e.g., via pip or pipx), they won't be available in your $PATH.
To fix this, run:
su -c py2droid-update-bin
This script:
- Generate wrappers for new executables found in Py2Droid's
$PATH - Remove obsolete wrappers that no longer have corresponding executables.
Changes take effect after a reboot.
Why not Termux?
Py2Droid was designed as a lightweight, system-level Python module — for cases where just Python is enough.
There are two main use cases where Py2Droid shines:
- A dependency for other Magisk modules or system-level scripts.
- A minimal standalone Python build, usable directly in the Android environment — without Termux, wrappers, or user-space hacks.
It's not meant to replace Termux — it's meant to serve a different purpose.
License
This project is licensed under the MIT license. See the LICENSE file for more details.