[Python] How do I use uv run with os.exec?

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running into a problem trying to use uv run with Python's os.exec variants. Any advice on how to get this to work?

    Bash, Ubuntu WSL, uv run python, execlp, uv 0.6.5:

    $ uv run python
    Python 3.12.9 (main, Feb 12 2025, 14:50:50) [Clang 19.1.6 ] on linux
    Type "help", "copyright", "credits" or "license" for more information.

    >>> import os
    >>> os.execlp("uv", "run", "python")
    Manage Python versions and installations

    Usage: run python [OPTIONS] <COMMAND>
    (rest of the help text here)


    Powershell, Windows 11, uv run main.py, execv, uv 0.6.10 (f2a2d982b 2025-03-25):

    PS > uv run python
    Python 3.12.9 (main, Mar 17 2025, 21:06:20) [MSC v.1943 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.

    >>> import os
    >>> os.execv(r"C:\Users\username\.local\bin\uv.exe", ["run", "main.py"])
    PS > error: unrecognized subcommand 'main.py'

    Usage: run [OPTIONS] <COMMAND>

    Continue reading...

Compartilhe esta Página