uv: uv not detecting python in termux
Disclaimer: I used AI to help write this report because English is not my first language, I apologize if anything is unclear or too detailed. Let me know if you need any clarifications
I’m encountering an issue when trying to use uv on Termux. When attempting to install packages using uv pip install, I receive an error indicating that no virtual environment or system Python installation is found, despite Python being installed and accessible.
Environment
- OS: Termux (Android)
- Python version: 3.11.9
- UV version: 0.4.10
- Termux version: 0.119.0-b1+monet36
- Android version: 14
- Device: vivo V2206
- CPU architecture: aarch64
- Kernel: Linux 4.19.157-perf+
Detailed Termux Information
Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_FILE=/data/app/~~NkwmZsImblhcEj3x0C3ZBQ==/com.termux-9tzZyDv4vcJKhizjsUGNtQ==/base.apk
TERMUX_APP__APK_RELEASE=GITHUB
TERMUX_APP__APP_VERSION_CODE=1020
TERMUX_APP__APP_VERSION_NAME=0.119.0-b1+monet36
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=true
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PID=31641
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-b1+monet36
TERMUX__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c218,c258,c512,c768
TERMUX__SE_INFO=default:targetSdkVersion=28:complete
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c218,c258,c512,c768
TERMUX__UID=10730
TERMUX__USER_ID=0
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
Steps to Reproduce
- Install
uvon Termux - Run
uv pip install scapy - Attempt to create a virtual environment using
uv venv - Try installing with
--systemflag:uv pip install scapy --system - Create a virtual environment using
python -m venv uvenv - Activate the virtual environment and repeat steps 2-4
Expected Behavior
The package should install successfully, either in a virtual environment or system-wide.
Actual Behavior
Receive errors indicating that no virtual environment or system Python installation is found, despite Python being correctly installed and accessible.
Detailed Debug Output
Attempt 1: Installing scapy with UV (outside virtual environment)
~ $ uv -v pip install scapy
DEBUG uv 0.4.10
DEBUG Searching for Python interpreter in system path
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3: Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python: Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3.11: Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
Attempt 2: Installing scapy with UV using --system flag
~ $ uv -v pip install scapy --system
DEBUG uv 0.4.10
DEBUG Searching for Python interpreter in system path
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3: Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python: Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3.11: Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
error: No system Python installation found
Attempt 3: Creating a virtual environment with UV
~ $ uv -v venv
DEBUG uv 0.4.10
DEBUG Searching for Python interpreter in managed installations or system path
DEBUG Searching for managed installations at `.local/share/uv/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3: Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python: Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3.11: Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Requested Python not found, checking for available download...
DEBUG Acquired lock for `.local/share/uv/python`
DEBUG Released lock at `/data/data/com.termux/files/home/.local/share/uv/python/.lock`
× No interpreter found in managed installations or
│ system path
Attempt 4: Installing scapy with UV (inside virtual environment)
(uvenv) ~ $ uv -v pip install scapy
DEBUG uv 0.4.10
DEBUG Searching for Python interpreter in system path
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python3: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python3: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python3.11: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3.11`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3: Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python: Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3.11: Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
Attempt 5: Installing scapy with UV using --system flag (inside virtual environment)
(uvenv) ~ $ uv -v pip install scapy --system
DEBUG uv 0.4.10
DEBUG Searching for Python interpreter in system path
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python3: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/home/uvenv/bin/python3.11: Can't use Python at `/data/data/com.termux/files/home/uvenv/bin/python3.11`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3: Can't use Python at `/data/data/com.termux/files/usr/bin/python3`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python: Can't use Python at `/data/data/com.termux/files/usr/bin/python`
DEBUG Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
DEBUG Skipping bad interpreter at /data/data/com.termux/files/usr/bin/python3.11: Can't use Python at `/data/data/com.termux/files/usr/bin/python3.11`
error: No system Python installation found
Python and UV versions
(uvenv) ~ $ which python
/data/data/com.termux/files/home/uvenv/bin/python
(uvenv) ~ $ python --version
Python 3.11.9
(uvenv) ~ $ uv --version
uv 0.4.10
Additional Observations
- UV consistently fails to detect or use any Python installation, whether system-wide or in a virtual environment.
- The error messages suggest that UV is unable to use the Python interpreters it finds, but doesn’t provide a specific reason why.
- The issue persists even after confirming that Python is correctly installed and accessible.
- Attempts to create a virtual environment with UV also fail due to the same interpreter detection issue.
- The problem occurs consistently across different scenarios and command variations, suggesting a fundamental issue with how UV interacts with the Python installation on Termux.
Attempted Solutions
- Upgraded Python:
$ pkg upgrade python python is already the newest version (3.11.9-5). - Tried both system-wide and virtual environment installations.
- Verified Python installation and accessibility.
Additional Notes
- The issue occurs both in and out of a virtual environment.
- Python is correctly installed and accessible, but UV seems unable to detect or use it.
- Termux is using the apt package manager.
- The Termux app is installed from GitHub (TERMUX_APP__APK_RELEASE=GITHUB).
Any assistance in resolving this issue would be greatly appreciated. Let me know if you need any additional information.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 18 (4 by maintainers)
Commits related to this issue
- Replace index with strchr Replaced deprecated index() functions with strchr(). Not sure if this is possible to do as drop-in replacement but this fixed my error, more about it here: https://github.co... — committed to MatiasHiltunen/sys-info-rs by MatiasHiltunen 2 years ago
- Fix Python interpreter discovery on non-glibc hosts (#9005) ## Summary On Termux, uv currently fails to find any interpreter because it can't find a glibc version, because there isn't one. But the P... — committed to astral-sh/uv by dead10ck 2 years ago
I have tested the new uv version 0.5.5 and it is working in termux now.
There are some warnings though.
I installed uv normally using pkg in Termux. The exact command I used was:
I didn’t download any binaries directly or use any special installation methods.
Your findings about the get_interpreter_info.py script are interesting. Is there a way for me to modify this script on my end to help diagnose the issue further? I’m willing to run any tests or provide any additional information that might be helpful in resolving this problem.
Also, given that the modified script you ran was able to detect the Python installation correctly, do you have any ideas about potential fixes or workarounds I could try?
No I don’t believe there has been a release yet that includes the fix
Has there been a release yet that includes the fix from the PR? We’d have to wait for pkg to also have the update on termux repos.
I have encountered similar errors with 0.51 version installed using pkg.
I tried multiple other installation methods with no success, this was first issue while building with cargo install:
For the Python-based installation using pipx:
This ssue appears to stem from the sys-info crate, specifically in c/linux.c. The code calls the index function, which is deprecated and not supported in ISO C99 or later. Android’s Bionic libc (used by Termux) is stricter and does not include this deprecated function.
I’m going to keep looking more into this as I suspect the issue is more related to external dependencies or env-variables that termux does differently.