Skip to content
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

Improve message when distutil is not available on legacy python. #4204

Open
mgaitan opened this issue Jun 10, 2024 · 3 comments
Open

Improve message when distutil is not available on legacy python. #4204

mgaitan opened this issue Jun 10, 2024 · 3 comments
Labels
error messages Messaging when something goes wrong help wanted Contribution especially encouraged tracing Verbose output and debugging

Comments

@mgaitan
Copy link

mgaitan commented Jun 10, 2024

I use a local venv in python3.10 but compile requirements for python 3.8 (requirements used for dockerized apps) . I have both versions (along the default python 3.12) installed.

Even when I have no my 3.10 venv active uv reports the following

warning: The requested Python version 3.8 is not available. 3.10.14 will be used . But if I run python3.8 it works.

tin@morocha:~/lab/Project-API$ make dependencies 
UV_CUSTOM_COMPILE_COMMAND="make dependencies" uv pip compile --python-version 3.8 --generate-hashes --output-file app/requirements/requirements-dev.txt app/requirements/requirements-dev.in
warning: The requested Python version 3.8 is not available; 3.10.14 will be used to build dependencies instead.
⠙ aiohttp==3.9.5                                                                                                                                                                              ^Cmake: *** [Makefile:17: app/requirements/requirements-dev.txt] Interrupción

tin@morocha:~/lab/Project-API$ python3.8
Python 3.8.19 (default, Apr 27 2024, 21:20:48) 
[GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
tin@morocha:~/lab/Project-API$ which python3.8
/usr/bin/python3.8
tin@morocha:~/lab/Project-API$ python
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
tin@morocha:~/lab/Project-API$ which python3.10
/usr/bin/python3.10
tin@morocha:~/lab/Project-API$ python3.10
Python 3.10.14 (main, Apr 27 2024, 21:17:55) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Debugging with --verbose I found the cause

DEBUG Starting interpreter discovery for Python 3.8
DEBUG Looking for exact match for request Python 3.8
DEBUG Searching for Python 3.8 in all sources
DEBUG Found CPython 3.10.14 at `/home/tin/lab/Project-API/.venv/bin/python3` (virtual environment)
DEBUG Querying Python at `/usr/bin/python3.8` failed with exit status exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tin/.cache/uv/.tmpy3nPfq/python/get_interpreter_info.py", line 555, in main
    "scheme": get_scheme(),
  File "/home/tin/.cache/uv/.tmpy3nPfq/python/get_interpreter_info.py", line 415, in get_scheme
    return get_distutils_scheme()
  File "/home/tin/.cache/uv/.tmpy3nPfq/python/get_interpreter_info.py", line 357, in get_distutils_scheme
    from distutils.dist import Distribution
ModuleNotFoundError: No module named 'distutils.dist'
---
DEBUG Found CPython 3.12.3 at `/usr/bin/python3` (search path)
DEBUG Found CPython 3.12.3 at `/usr/bin/python` (search path)
DEBUG Querying Python at `/bin/python3.8` failed with exit status exit status: 1
--- stdout:

so after installing sudo apt install python3.8-distutils it works.

The error message could be clearer and indicate the exact issue, such as the missing distutils module, to help users resolve the problem more efficiently.

@zanieb zanieb added error messages Messaging when something goes wrong tracing Verbose output and debugging labels Jun 10, 2024
@zanieb
Copy link
Member

zanieb commented Jun 10, 2024

Thanks for the report. It should be relatively straight-forward to add a try/except with a better message in get_interpreter_info if someone is interested.

@mgaitan
Copy link
Author

mgaitan commented Sep 12, 2024

is this fixed in #7239 ?

@acarapetis
Copy link

is this fixed in #7239 ?

Nope, ran into this today with uv 0.5.1.

@zanieb zanieb added the help wanted Contribution especially encouraged label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong help wanted Contribution especially encouraged tracing Verbose output and debugging
Projects
None yet
Development

No branches or pull requests

3 participants