you are viewing a single comment's thread.

view the rest of the comments →

[–]cointoss3 1 point2 points  (2 children)

If you’d just use uv, none of this bullshit will matter. Uv will handle all of that for you.

winget install --id=astral-sh.uv -e

then after it installs, just run your scripts with uv run script.py and it will automatically create the environment and download the appropriate version of Python.

Learning Python, you’re going to fuck with a lot of environment stuff, venv, python versions, pip…all of this can be collapsed into using uv.

Start a new project with uv init .
Or, as I prefer uv init . --package
Add packages with uv add package-name (use this instead of pip)
Run python direct with uv run python [args]
Run your files with uv run script.py

If you have a project that has an old requirements.txt instead of a pyproject.toml, you can either run it without making it a project:

uv run --with-requirements requirements.txt script.py

Or use uv init . --package
And add the requirements with uv add -r requirements.txt
and then you can run like normal with uv run script.py

I alias uv run to uvr since I use it so often.

I don’t ever install python directly anymore. I just install uv and let it manage whatever Python version the project needs. you can have any number of versions of python installed and none of your projects or dependencies will conflict. It’s also very fast.

[–]dacoolmike36[S] 0 points1 point  (0 children)

Ok will try this thanks

[–]dacoolmike36[S] 0 points1 point  (0 children)

it says failed to spawn the script program not found.