#python tips for folks getting started.
Don't use the system-level python as that can update and break dependencies. E.g. Arch uses 3.13 if you update and Tensorflow can't go above 3.12.
Use pyenv to do version management per project. https://github.com/pyenv/pyenv
Don't install pip dependencies globally. Use virtualenv to set up dependencies per project. https://virtualenv.pypa.io/
Python versioning is rough out of the box and these tips can save you some pain.
@carlos Sweet, thanks for the link!
@mauve this is a great tip! I would add that when I teach beginners that are not familiar with the command line, I recommend they try #ThonnyIDE https://thonny.org, a nice code editor for #Python that also provides a simple way of having isolated virtual environments where you can experiment and install stuff without fear of breaking your system.
@villares Neat. For sandboxes I like to use JupyterLite in browsers to skip having to install anything natively.
@mauve This is reasonable advice, even pip gives me a warning that I should do this! However, I do not agree with this approach 100%. Often I am using a single-application virtual machine or container, in which case I don't need separate per-project virtual environments. Also, there are too many python virtual environment managers to choose from. Finally, sometimes using a virtual environment (specifically, virtualenv) is not compatible with the fish shell that I use. I prefer simplicity.
@brandon Yeah focusing on containers is a reasonable approach. I usually lean the opposite and try to be as close to the metal as possible with as few dependencies or little sophistication I can get away with. Usually just to speed up boostrapping on raw machines with limited configuration. Fish is neat! I've just pimped my bash to be less painful :P
@brandon Have you messed with Qubes OS? I've been considering setting a machine up with it to see how it goes.
@mauve I would even encourage to use uv instead of pyenv+pip+virtualenv since it integrates all of their fonctionnalities in one coherent tool :
https://docs.astral.sh/uv/#highlights
Having only one tool to manage all the python environnement stuff is really a good thing for beginners (and advanced user too !).
#python #tips
or #uv https://docs.astral.sh/uv/