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

  1. Install uv on Termux
  2. Run uv pip install scapy
  3. Attempt to create a virtual environment using uv venv
  4. Try installing with --system flag: uv pip install scapy --system
  5. Create a virtual environment using python -m venv uvenv
  6. 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

  1. UV consistently fails to detect or use any Python installation, whether system-wide or in a virtual environment.
  2. The error messages suggest that UV is unable to use the Python interpreters it finds, but doesn’t provide a specific reason why.
  3. The issue persists even after confirming that Python is correctly installed and accessible.
  4. Attempts to create a virtual environment with UV also fail due to the same interpreter detection issue.
  5. 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

  1. Upgraded Python:
    $ pkg upgrade python
    python is already the newest version (3.11.9-5).
    
  2. Tried both system-wide and virtual environment installations.
  3. 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

Most upvoted comments

I have tested the new uv version 0.5.5 and it is working in termux now.

$ uv python find
/data/data/com.termux/files/usr/bin/python

$ uv python list
cpython-3.12.7-linux-aarch64-none    /data/data/com.termux/files/usr/bin/python3.12
cpython-3.12.7-linux-aarch64-none    /data/data/com.termux/files/usr/bin/python3 -> python3.12
cpython-3.12.7-linux-aarch64-none    /data/data/com.termux/files/usr/bin/python -> python3.12

There are some warnings though.

$ uv venv venv
Using CPython 3.12.7 interpreter at: /data/data/com.termux/files/usr/bin/python
Creating virtual environment at: venv
Activate with: source venv/bin/activate

$ uv pip install pathlib2
Using Python 3.12.7 environment at: venv
Resolved 2 packages in 869ms
Prepared 2 packages in 77ms
░░░░░░░░░░░░░░░░░░░░ [0/2] Installing wheels...
         warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 2 packages in 8ms
 + pathlib2==2.3.7.post1
 + six==1.16.0

Interesting, seems like uv is not detecting python in Android (installed as part of the Termux APK). How did you install uv within Termux? Downloading an aarch64 binary directly?

I installed uv normally using pkg in Termux. The exact command I used was:

pkg install uv

I didn’t download any binaries directly or use any special installation methods.

I decided to give it a quick try, and check if get_interpreter_info.py even works, but it was definitely going the branch of

print(json.dumps({“result”: “error”, “kind”: “libc_not_found”})) sys.exit(0) which is likely the main culprit here to some degree.

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:

error: subprocess-exited-with-error
warning: sys-info@0.9.1: c/linux.c:96:11: error: call to undeclared library function 'index' with type 'char *(const char *, int)';
ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
error: failed to run custom build command for `sys-info v0.9.1`

For the Python-based installation using pipx:

pip failed to build package:
    uv

Some possibly relevant errors from pip install: 
error: subprocess-exited-with-error           warning: sys-info@0.9.1: c/linux.c:96:11: error: call to undeclared library function 'index' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    error: failed to run custom build command for `sys-info v0.9.1`
    cargo:warning=c/linux.c:96:11: error: call to undeclared library function 'index' with type 'char *(const char *, int)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]            Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/data/data/com.termux/files/home/.local/share/pipx/venvs/uv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1                                         ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (uv)

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.