Termux is an Android APP that can run a Terminal terminal inside Android, that is to say, it makes shell available on Android. But the entire Termux project is not just as simple as a terminal emulator, it includes a complete set of tool chains to allow Android to use shells (bash, zsh, fish, etc.), as well as various Linux program applications (python, perl, gcc, etc.).
Running Termux is equivalent to having an entire apt software warehouse that can run directly on Android. This apt software repository is compiled based on NDK, and it is a binary running mode natively supported by Android, which can be more easily transplanted to run in other Android apps.
pkg search xx # e.g. pkg search sh lists all *sh* packages
pkg install xxx
P.S. The apt
command can also be used, but the pkg
command is more recommended. Technically detailed explanation: pkg
is actually a bash script, and the bottom layer still calls apt
, but pkg
will handle more boundary conditions, mirror load balancing and other logic.
pkg install python # pretty easy, right
pip install xxx
Note: Due to the "magic change" of $HOME
, the old version pip
cannot recognize (while the new version can) ~/.pip/pip.conf
, so the configuration in pip.conf
may not take effect under old version pip
.
However, we can still manually specify pypi mirror if we want to:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx # using custom mirror
Some pip packages can't recognize the modified $HOME either, using proot to cheat and improve compabitily:
proot -0 pip install xxx
pkg search opencv # we can see two packages: opencv and opencv-python
pkg install opencv opencv-python
# then we verify if opencv-python has been successfully installed
python -c import cv2; print(cv2.__version__)
# will output opencv's installed version if success
Simply put, if pkg repository provides a corresponding python library (use pkg search python
to search for all supported Python libraries), then you should use pkg command first; otherwise, the alternative is pip installation.
The Termux project contains many git repos,can be found in https://github.com/orgs/termux/repositories?type=all.
The following introduces several commonly used important Termux repos.
Later, there will be a special topic to bring you more detailed Termux advanced usage guide.
Let's Make Android great (again), with Termux!