• Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    5 hours ago

    yeah, all that setup sucks even after being writing python for years.

    Nowadays I’ve been running every project with uv and it’s a much better and faster experience, usually in 3 steps: 1. initialize, 2. add dependencies, 3. run project:

    
    # if the project doesn't already have a pyproject.toml with dependencies, initialize it
    # uv will also install the right interpreter if not present:
    uv init --python 3.13
    
    # anything you would install with pip, use uv add:
    uv add dep1 dep2
    
    # run the project / script
    uv run main.py
    
    

    Then in future runs (as long as you have the pyproject.toml), you can just do uv run main.py (shorthand to uv run python main.py), even when there’s no venv created. No more activating virtual envs. No more long interpreter installations. No more accidentally messing with system’s packages or the PATH variable. With the uv.lock that’s also a lot more reliable to reproduce than requirements.txt and similar.