- Python Compilers Idle
- Python Runner For Android App
- Python Runner Download
- Python Runner For Android Studio
QPython - Python on Android. In most cases, script can get your jobs done as good as the native application. Now you can make it with QPython's help. QPython is a script engine which runs Python programs on android devices. It also can help developers develop android applications.
QPython is the Python engine for android.it already has millions of users worldwide and it is also an open source project. It contains some amazing features such as. Android Python interpreter; Python android runtime environment. Python editor; QPYI and SL4A library; It supports running multiple types of projects, including: console program. To start Android app development with Python, there are various platforms that enable us to write the codes purely in Python. We can use python for web development, app development, analysis and computation of scientific and numeric data and software development.
Getting up and running on python-for-android (p4a) is a simple processand should only take you a couple of minutes. We’ll refer to Pythonfor android as p4a in this documentation.
Concepts¶
Basic:
- requirements: For p4a, all your app’s dependencies must be specifiedvia
--requirements
similar to the standard requirements.txt.(Unless you specify them via a setup.py/install_requires)All dependencies will be mapped to “recipes” if any exist, so thatmany common libraries will just work. See “recipe” below for details. - distribution: A distribution is the final “build” of yourcompiled project + requirements, as an Android project assembled byp4a that can be turned directly into an APK. p4a can contain multipledistributions with different sets of requirements.
- build: A build refers to a compiled recipe or distribution.
- bootstrap: A bootstrap is the app backend that will start yourapplication. The default for graphical applications is SDL2.You can also use e.g. the webview for web apps, or service_only forbackground services. Different bootstraps have different additionalbuild options.
Advanced:
- recipe:A recipe is a file telling p4a how to install a requirementthat isn’t by default fully Android compatible.This is often necessary for Cython or C/C++-using python extensions.p4a has recipes for many common libraries already included, and anydependency you specified will be automatically mapped to its recipe.If a dependency doesn’t work and has no recipe included in p4a,then it may need one to work.
Installation¶

Installing p4a¶
p4a is now available on Pypi, so you can install it using pip:
You can also test the master branch from Github using:
Installing Dependencies¶
p4a has several dependencies that must be installed:
- ant
- autoconf (for libffi and other recipes)
- automake
- ccache (optional)
- cmake (required for some native code recipes like jpeg’s recipe)
- cython (can be installed via pip)
- gcc
- git
- libncurses (including 32 bit)
- libtool (for libffi and recipes)
- libssl-dev (for TLS/SSL support on hostpython3 and recipe)
- openjdk-8
- patch
- python3
- unzip
- virtualenv (can be installed via pip)
- zlib (including 32 bit)
- zip
On recent versions of Ubuntu and its derivatives you may be able toinstall most of these with:
On Arch Linux you should be able to run the following toinstall most of the dependencies (note: this list may not becomplete):
On macOS:
Installing Android SDK¶
Warning
python-for-android is often picky about the SDK/NDK versions.Pick the recommended ones from below to avoid problems.
Basic SDK install¶
You need to download and unpack the Android SDK and NDK to a directory (let’s say $HOME/Documents/):
For the Android SDK, you can download ‘just the command linetools’. When you have extracted these you’ll see only a directorynamed tools
, and you will need to run extra commands to installthe SDK packages needed.
For Android NDK, note that modern releases will only work on a 64-bitoperating system. The minimal, and recommended, NDK version to use is r19b:
- Windows users should create a virtual machine with an GNU Linux osinstalled, and then you can follow the described instructions from withinyour virtual machine.
Platform and build tools¶
First, install an API platform to target. The recommended *target* APIlevel is 27, you can replace it with a different number butkeep in mind other API versions are less well-tested and older devicesare still supported down to the recommended specified *minimum*API/NDK API level 21:
Second, install the build-tools. You can use$SDK_DIR/tools/bin/sdkmanager--list
to see all thepossibilities, but 28.0.2 is the latest version at the time of writing:
Configure p4a to use your SDK/NDK¶
Then, you can edit your ~/.bashrc
or other favorite shell to include new environmentvariables necessary for building on android:
You have the possibility to configure on any command the PATH to the SDK, NDK and Android API using:
--sdk-dirPATH
as an equivalent of $ANDROIDSDK--ndk-dirPATH
as an equivalent of $ANDROIDNDK--android-apiVERSION
as an equivalent of $ANDROIDAPI--ndk-apiVERSION
as an equivalent of $NDKAPI--ndk-versionVERSION
as an equivalent of $ANDROIDNDKVER
Usage¶
Build a Kivy or SDL2 application¶
To build your application, you need to specify name, version, a packageidentifier, the bootstrap you want to use (sdl2 for kivy or sdl2 apps)and the requirements:
Note on--requirements
: you must add alllibraries/dependencies your app needs to run.Example: --requirements=python3,kivy,vispy
. For an SDL2 app,kivy is not needed, but you need to add any wrappers you mightuse (e.g. pysdl2).
This p4a apk … command builds a distribution with python3,kivy, and everything else you specified in the requirements.It will be packaged using a SDL2 bootstrap, and producean .apk file.
Compatibility notes:
- Python 2 is no longer supported by python-for-android. The last release supporting Python 2 was v2019.10.06.
Build a WebView application¶
To build your application, you need to have a name, version, a packageidentifier, and explicitly use the webview bootstrap, aswell as the requirements:
Please note as with kivy/SDL2, you need to specify all youradditional requirements/dependencies.
You can also replace flask with another web framework.
Replace --port=5000
with the port on which your app will serve awebsite. The default for Flask is 5000.
Other options¶
You can pass other command line arguments to control app behaviourssuch as orientation, wakelock and app permissions. SeeBootstrap options.
Rebuild everything¶
If anything goes wrong and you want to clean the downloads and builds to retry everything, run:
If you just want to clean the builds to avoid redownloading dependencies, run:
Getting help¶
If something goes wrong and you don’t know how to fix it, add the--debug
option and post the output log to the kivy-users Googlegroup or thekivy #support Discord channel.
See Troubleshooting for more information.
Advanced usage¶
Recipe management¶
You can see the list of the available recipes with:
If you are contributing to p4a and want to test a recipes again,you need to clean the build and rebuild your distribution:
You can write “private” recipes for your application, just create ap4a-recipes
folder in your build directory, and place a recipe init (edit the __init__.py
):
Distribution management¶
Every time you start a new project, python-for-android will internallycreate a new distribution (an Android build project including Pythonand your other dependencies compiled for Android), according to therequirements you added on the command line. You can force the reuse ofan existing distribution by adding:
This will ensure your distribution will always be built in the samedirectory, and avoids using more disk space every time you adjust arequirement.
Python Compilers Idle
You can list the available distributions:
And clean all of them:
Configuration file¶
python-for-android checks in the current directory for a configurationfile named .p4a
. If found, it adds all the lines as options to thecommand line. For example, you can add the options you would alwaysinclude such as:
Python Runner For Android App
Overriding recipes sources¶
You can override the source of any recipe using the$P4A_recipename_DIR
environment variable. For instance, to testyour own Kivy branch you might set:
The specified directory will be copied into python-for-android insteadof downloading from the normal url specified in the recipe.
setup.py file (experimental)¶
Python Runner Download
If your application is also packaged for desktop using setup.py,you may want to use your setup.py instead of the--requirements
option to avoid specifying things twice.For that purpose, check out distutils/setuptools integration
Going further¶
See the other pages of this doc for more information on specific topics:
Latest versionReleased:
Android APK packager for Python scripts and apps
Project description
python-for-android is a packaging tool for Python apps on Android. You cancreate your own Python distribution including the modules anddependencies you want, and bundle it in an APK along with your own code.
Features include:
- Different app backends including Kivy, PySDL2, and a WebView withPython webserver.
- Automatic support for most pure Python modules, and built in supportfor many others, including popular dependencies such as numpy andsqlalchemy.
- Multiple architecture targets, for APKs optimised on any givendevice.
For documentation and support, see:
- Website: http://python-for-android.readthedocs.io
- Mailing list: https://groups.google.com/forum/#!forum/kivy-users orhttps://groups.google.com/forum/#!forum/python-android.
Python Runner For Android Studio
Documentation
Follow the quickstartinstructionsto install and begin creating APKs.
Quick instructions: install python-for-android with:
(for the develop branch: pip install git+https://github.com/kivy/python-for-android.git
)
Test that the install works with:
To build any actual apps, set up the Android SDK and NDKas described in the quickstart.Use the SDK/NDK API level & NDK version as in the quickstart,other API levels may not work.
With everything installed, build an APK with SDL2 with e.g.:
For full instructions and parameter options, see thedocumentation.
Support
If you need assistance, you can ask for help on our mailing list:
- User Group: https://groups.google.com/group/kivy-users
- Email: kivy-users@googlegroups.com
We also have #support Discord channel.
Contributing
We love pull requests and discussing novel ideas. Check out the Kivyproject contribution guide andfeel free to improve python-for-android.
See ourdocumentationfor more information about the python-for-android development andrelease model, but don't worry about the details. You just need tomake a pull request, we'll take care of the rest.
The following mailing list and IRC channel are used exclusively fordiscussions about developing the Kivy framework and its sister projects:
- Dev Group: https://groups.google.com/group/kivy-dev
- Email: kivy-dev@googlegroups.com
We also have #dev Discord channel.
License
python-for-android is released under the terms of the MIT License.Please refer to the LICENSE file.
History
In 2015 these tools were rewritten to provide a new, easier-to-use andeasier-to-extend interface. If you'd like to browse the old toolchain, itsstatus is recorded for posterity at athttps://github.com/kivy/python-for-android/tree/old_toolchain.
In the last quarter of 2018 the python recipes were changed. Thenew recipe for python3 (3.7.1) had a new build system which wasapplied to the ancient python recipe, allowing us to bump the python2version number to 2.7.15. This change unified the build process forboth python recipes, and probably solved various issues detected over theyears. These unified python recipes require a minimum target api level of 21,Android 5.0 - Lollipop. If you need to build targeting anapi level below 21, you should use an older version of python-for-android(<=0.7.1).
On March of 2020 we dropped support for creating apps that use Python 2. The latestpython-for-android release that supported building Python 2 was version 2019.10.6.
Contributors
This project exists thanks to all the people who contribute. [Contribute].
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
Release historyRelease notifications | RSS feed
2021.9.5
2020.6.2
2020.4.29
2020.3.30
2019.10.6
2019.8.9
2019.7.8
2019.6.6.post0
2019.6.6
0.7.0
0.6.0
0.5.3
0.5.2
0.5.1
0.5
0.4

0.3
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size python_for_android-2021.9.5-py3-none-any.whl (516.5 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size python-for-android-2021.9.5.tar.gz (985.0 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for python_for_android-2021.9.5-py3-none-any.whl
Algorithm | Hash digest |
---|---|
SHA256 | 383254500966739d42766318ed508e90d05c7907096bead48a1076c67797a2d3 |
MD5 | 0d575f463033f5f5285500191b31805f |
BLAKE2-256 | 08675395480ec4346434cc5a1c11ab1f19c7a6b742f42a6f2e45b4842ecfaac9 |
Hashes for python-for-android-2021.9.5.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | 46305120df040d964514a02b7a5cbc93048d1a69ef9ad67d14cd6cdac536337c |
MD5 | 1c2ad32a574109dd20a857774f77bae3 |
BLAKE2-256 | 8712d6825fbd0ee7e3da541cda4d71c3b8e6621b3926ac72e11c4c23e0c169c1 |