When trying to install Python packages on Termux, you get compilation errors:
ERROR: Failed building wheel for grpcio
Command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed
ERROR: Failed building wheel for Pillow
× Building wheel for Pillow (pyproject.toml) did not run successfully.
ERROR: Failed to build 'cryptography' when installing build dependencies
Rust not found, installing into a temporary directory
Unsupported platform: 312
All three packages require native compilation:
- C++ library for gRPC
- Needs Android NDK
- Platform detection fails
- Image processing library
- Needs libjpeg, libpng, zlib
- C extensions won't compile
- Cryptographic library
- Written in Rust
- Requires Rust compiler + toolchain
- Compilation fails on Android
# WRONG (all fail):
pip install google-generativeai # tries to build grpcio
pip install Pillow # tries to compile C code
pip install cryptography # tries to compile Rust code
# CORRECT:
pkg install python-grpcio python-pillow python-cryptography
pip install --no-deps google-generativeai
pip install google-ai-generativelanguage protobufpkg update && pkg upgrade -y
pkg install python git termux-api python-grpcio python-pillow python-cryptography -ygit clone https://github.com/Alex72-py/gemini-cli-termux.git
cd gemini-cli-termux# Install pure Python packages (native libs excluded)
pip install --break-system-packages -r requirements.txt# grpcio, Pillow, and cryptography already installed via pkg
# Install google-generativeai WITHOUT trying to rebuild them
pip install --break-system-packages --no-deps google-generativeai
# Install other dependencies of google-generativeai
pip install --break-system-packages google-ai-generativelanguage protobufpip install --break-system-packages -e .python -c "import grpc; print('✓ grpcio:', grpc.__version__)"
python -c "from PIL import Image; print('✓ Pillow: OK')"
python -c "import cryptography; print('✓ cryptography: OK')"
python -c "import google.generativeai as genai; print('✓ google-generativeai: OK')"
gemini-termux --versionThe install.sh script handles this automatically:
chmod +x install.sh
./install.shIt will:
- Install
python-grpciovia pkg - Install requirements.txt (without google-generativeai)
- Install google-generativeai with --no-deps
- Install google-generativeai's other dependencies
- Install the CLI
pip install google-generativeai
└─> Tries to install grpcio
└─> Tries to compile C++ code
└─> ❌ FAILS on Termux
pkg install python-grpcio ← Pre-compiled binary
✓ Installed
pip install --no-deps google-generativeai
✓ Installed (doesn't try to install grpcio)
pip install google-ai-generativelanguage protobuf
✓ Installed (pure Python packages)
- Source: Termux official repositories
- Version: Usually 1.60.x - 1.70.x
- Architecture: Pre-compiled for ARM64/ARM32
- Installation:
pkg install python-grpcio
- Dependencies: grpcio, google-ai-generativelanguage, protobuf
- Installation:
pip install --no-deps google-generativeai - Why --no-deps: Prevents pip from trying to install grpcio
# This will FAIL:
pip install google-generativeai
# This will also FAIL:
pip install grpcio# Use Termux package manager for grpcio:
pkg install python-grpcio
# Then use pip with --no-deps:
pip install --break-system-packages --no-deps google-generativeai-
Missing Android NDK
- grpcio build requires Android NDK
- Termux doesn't provide NDK
-
Platform Detection
- grpcio doesn't recognize Android
- Tries to use Linux compilation flags
- Fails with Android-specific errors
-
Header Files
- Missing:
sys/epoll.h, various C++ headers - Android versions have different headers
- API level mismatches
- Missing:
-
Compiler Issues
aarch64-linux-android-clangdifferences- Incompatible flags
- Linker errors
- Pre-compiled on Termux build servers
- Correct Android NDK configuration
- Platform-specific patches applied
- Binary distribution (no compilation needed)
| Package | Version | Method | Status |
|---|---|---|---|
| grpcio | 1.60+ | pkg | ✅ Works |
| grpcio | any | pip | ❌ Fails |
| google-generativeai | 0.8.0+ | pip (with --no-deps) | ✅ Works |
| google-generativeai | any | pip (normal) | ❌ Fails (tries to build grpcio) |
The key to success:
- Install
python-grpcio,python-pillow, ANDpython-cryptographyviapkg(not pip) - Install
google-generativeaiwith--no-depsflag - Manually install other dependencies
All three packages are handled automatically by the install.sh script!
Updated: February 13, 2026
Status: ✅ FIXED - All three native dependencies resolved (grpcio, Pillow, cryptography)