-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uv not detecting python in termux #7373
Comments
Interesting, seems like uv is not detecting python in Android (installed as part of the Termux APK). 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
which is likely the main culprit here to some degree. I modified it to return {
"result": "success",
"markers": {
"implementation_name": "cpython",
"implementation_version": "3.11.9",
"os_name": "posix",
"platform_machine": "aarch64",
"platform_python_implementation": "CPython",
"platform_release": "[Redacted Android Release ID]",
"platform_system": "Linux",
"platform_version": "[Redacted Android Version ID]",
"python_full_version": "3.11.9",
"python_version": "3.11",
"sys_platform": "linux"
},
"sys_base_prefix": "/data/data/com.termux/files/usr",
"sys_base_exec_prefix": "/data/data/com.termux/files/usr",
"sys_prefix": "/data/data/com.termux/files/usr",
"sys_base_executable": "/data/data/com.termux/files/usr/bin/python",
"sys_executable": "/data/data/com.termux/files/usr/bin/python",
"sys_path": [
"/data/data/com.termux/files/home",
"/data/data/com.termux/files/usr/lib/python311.zip",
"/data/data/com.termux/files/usr/lib/python3.11",
"/data/data/com.termux/files/usr/lib/python3.11/lib-dynload",
"/data/data/com.termux/files/usr/lib/python3.11/site-packages"
],
"stdlib": "/data/data/com.termux/files/usr/lib/python3.11",
"scheme": {
"platlib": "/data/data/com.termux/files/usr/lib/python3.11/site-packages",
"purelib": "/data/data/com.termux/files/usr/lib/python3.11/site-packages",
"include": "/data/data/com.termux/files/usr/include/python3.11",
"scripts": "/data/data/com.termux/files/usr/bin",
"data": "/data/data/com.termux/files/usr"
},
"virtualenv": {
"purelib": "lib/python3.11/site-packages",
"platlib": "lib/python3.11/site-packages",
"include": "include/site/python3.11",
"scripts": "bin",
"data": ""
},
"platform": {
"os": {
"name": "unknown",
"major": -1,
"minor": -1
},
"arch": "aarch64"
},
"manylinux_compatible": true,
"gil_disabled": false,
"pointer_size": "64"
} |
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? |
@Noth1ngLol Did you solve the problem? If so, can you share your solution? |
Came here because of the same problem. I think the issue was closed prematurely? It's probably a duplicate of #2408 anyway. |
Let's use this issue to track the Python interpreter query bug and #2408 to track broader support. |
@samypr100 so does |
Sorry, I did not recompile uv with the changes on Android to be able to test that. |
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. |
I tried my hand at this in #9005. Not sure if this is a good solution, but it seems to work. |
Good to know that there is a solution! Have you tried building the project in termux with these changes? |
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: astral-sh/uv#7373 (comment)
About the build error that I posted, there is a pending PR that worked for me to fix the issue above that I got during build process: FillZpp/sys-info-rs#118 Not sure how actively maintained the sys-info crate is as last commit has been 2 years ago |
## 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 Python interpreter is still functional nonetheless. So, when glibc cannot be found, simply return 0 for the version numbers and mark the interpreter as being incompatible with manylinux I really don't know if this is the right way to address this, but I can attest that manual testing shows uv appears to be fully functional, at least for pip and virtualenvs. Fixes #7373 ## Test Plan I tried running the test suite, and after some tweaks, a good portion of the test suite passes as well. A significant number of tests fail, but this appears to be due to minor differences in output, like warnings about hard links not working (hard links are completely disallowed on Android), differences in the number of files removed, etc. The test suite seems to be very sensitive to minor variations in output.
Fyi: I just tried and Here is what I did: pkg install uv
uv --version
# uv 0.5.4
python --version
# Python 3.12.7
which python
# /data/data/com.termux/files/usr/bin/python
uv python find 3.12
# error: No interpreter found for Python 3.12 in virtual environments, managed installations, or search path Installing a new version does also not work: uv python install 3.11
# error: No download found for request: cpython-3.11-linux-aarch64-none Cheers |
Also as long as the sys-info (v.0.9.1) crate is there it is not possible to use other installation methods that involves build process due to android 14(?) compiler restrictions with deprecated C-code. I think I saw somewhere discussion about replacing sys-info crate with more up-to-date crate, couldn't find it anymore though. With rust I have noticed that many crates that target android as a platform can not be compiled to termux because platform is detected to be aarch64-linux-android and those packages expect (correctly) to bind to android activity as they would if we were building android application, even though termux does not need the program to bind to android activity to work. When activity is not found, compile can not go trough. In some cases, I have modified the platform detection code so that compiler skips the activity check and build goes nicely through natively to aarch64-linux-android. This is not a good practise though. Perhaps this is a discussion that should be taken to Termux (or rust) community and see if there is something that could be done to help rust compiler to detect termux better as emulated linux environment and prevent the rust from expecting the android activity to be available when its not needed? |
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. |
No I don't believe there has been a release yet that includes the fix |
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 usinguv pip install
, I receive an error indicating that no virtual environment or system Python installation is found, despite Python being installed and accessible.Environment
Detailed Termux Information
Steps to Reproduce
uv
on Termuxuv pip install scapy
uv venv
--system
flag:uv pip install scapy --system
python -m venv uvenv
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)
Attempt 2: Installing scapy with UV using --system flag
Attempt 3: Creating a virtual environment with UV
Attempt 4: Installing scapy with UV (inside virtual environment)
Attempt 5: Installing scapy with UV using --system flag (inside virtual environment)
Python and UV versions
Additional Observations
Attempted Solutions
Additional Notes
Any assistance in resolving this issue would be greatly appreciated. Let me know if you need any additional information.
The text was updated successfully, but these errors were encountered: