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

uv venv fails because python3.wrapper is not available #1868

Closed
csalerno-asml opened this issue Feb 22, 2024 · 16 comments
Closed

uv venv fails because python3.wrapper is not available #1868

csalerno-asml opened this issue Feb 22, 2024 · 16 comments
Labels
bug Something isn't working virtualenv Related to virtual environments

Comments

@csalerno-asml
Copy link

Machine: RHEL7

$ python3 -m pip install uv==0.1.7
$ uv venv
Querying Python at `/home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper` failed with status exit status: 127:
  │ --- stdout:

  │ --- stderr:
  │ /home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper: line 5: python3.wrapper: command not found
  │ ---
@konstin
Copy link
Member

konstin commented Feb 22, 2024

How did you install python?

@Crissal1995
Copy link

Via a proprietary enterprise tool, so some shenanigans are happening with paths.

However running python3 -m venv .venv works correctly, shouldn't uv run the same command?

@zanieb
Copy link
Member

zanieb commented Feb 24, 2024

uv implements its own virtual environment creation in Rust, we do not call Python's virtual environment tooling.

@Crissal1995
Copy link

Isn't possible to implement a fallback in case of custom python installations?

@konstin
Copy link
Member

konstin commented Feb 26, 2024

Could you run with debug logging?

RUST_LOG=debug uv venv -v

For background, we rely on python -c "<our probing script>" to get information about the python interpreter (e.g. its version and its paths). Is there a reason why python -m venv works while python -c doesn't?

@csalerno-asml
Copy link
Author

csalerno-asml commented Feb 28, 2024

There you go:

$ RUST_LOG=debug uv venv -v
 uv_interpreter::python_query::find_default_python platform=Platform { os: Manylinux { major: 2, minor: 17 }, arch: X86_64 }, cache=Cache { root: "/home/csalerno/.cache/uv", refresh: None, _temp_dir_drop: None }
      0.016782s  11ms DEBUG uv_interpreter::interpreter Detecting markers for: /home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper
  × Querying Python at `/home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper` failed
  │ with status exit status: 127:
  │ --- stdout:

  │ --- stderr:
  │ /home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper: line 5: python3.wrapper:
  │ command not found
  │ ---

Regarding your question, not sure, maybe some enterprise rules, however python -c works fine.

$ python -c 'print("hello world")'
hello world

However in our setup, python is v2.7.14, while python3 is v3.10.5, so maybe python2 is actually called by uv?

@MichaReiser
Copy link
Member

However in our setup, python is v2.7.14, while python3 is v3.10.5, so maybe python2 is actually called by uv?

uv calls python 2 to get its version information. But it won't use it if you have a Python3 installation.

Can you run which python and would you mind sharing the content of cat /home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper (assuming it contains no sensitive content)? I wonder if it fails because we canonicalize the path

@csalerno-asml
Copy link
Author

Sure, no sensitive content found :)

which python

/home/csalerno/.caddir/RHEL7/cadbin/python

cat /home/cadappl_RHEL7/python3/3.10.5/wrapper/python3.wrapper

#!/bin/sh
export PATH=/cadappl/python3/3.10.5/python3/bin:${PATH}
export LD_LIBRARY_PATH=/cadappl/python3/3.10.5/python3/lib:/cadappl/tcl/8.6.11/tcl/lib:/cadappl/tk/8.6.11/tk/lib:/cadappl/sqlite/3.34.1/sqlite/lib:/cadappl/zlib/1.2.11/lib:/cadappl/openssl/1.1.1j/openssl/lib:/cadappl/valgrind/3.16.1/valgrind/lib:/cadappl/gdbm/1.19/gdbm/lib:/cadappl/readline/6.2.4.1/readline/lib:/cadappl/bzip2/1.0.6.a/bzip2/lib:${LD_LIBRARY_PATH}

`basename $0` "$@"

@konstin
Copy link
Member

konstin commented Mar 1, 2024

It's probably because we resolve the symlink so the basename changes

@csalerno-asml
Copy link
Author

is there a workaround that I could apply in python3.wrapper? or this is something that should be fixed in uv?

@charliermarsh
Copy link
Member

@konstin - Related to #1640 -- I'm unsure if we should be resolving symlinks for interpreters outside of virtualenvs.

@konstin
Copy link
Member

konstin commented Mar 3, 2024

We should stop resolving the symlinks unconditionally; Initially, it looked like a convenient solution for venv-from-venv use cases, but using sys._base_executable with a fallback to resolving should represent the user intent better.

@charliermarsh
Copy link
Member

@konstin - I generally agree, although if we change that, it will "break" cases like this: pypa/virtualenv#2682. (That issue motivated virtualenv to start recursively resolving symlinks (on main but unreleased).)

@konstin
Copy link
Member

konstin commented Mar 3, 2024

I've asked at python/cpython#106045 (comment), this should bring some clarity

@charliermarsh charliermarsh added bug Something isn't working virtualenv Related to virtual environments labels Mar 4, 2024
@Crissal1995
Copy link

Hi, is there any update regarding this issue?

@konstin
Copy link
Member

konstin commented Jul 1, 2024

We've rewritten interpreter discovery and this should not occur anymore, feel free to reopen if it's still a problem.

@konstin konstin closed this as completed Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working virtualenv Related to virtual environments
Projects
None yet
Development

No branches or pull requests

6 participants