5 ms·
You need three things usually: - virtual environment (python3 -m venv --help) - pip for manually installing things - poetry for declaratively installing thin
by vegai_ 4y ago
You need three things usually:
- virtual environment (python3 -m venv --help)
- pip for manually installing things
- poetry for declaratively installing things
For a UX point of view, this is already pretty good and tends to work well. What sometimes makes this awkward and inefficient is that many python projects either don't declare their dependencies at all, or declare them with very specific versions. This makes it apparently a necessity for the resolver to do things quite heuristically.
- BozeWolf 4y agoFour things: you also want to specify a python version. Some projects run fine on 3.5, some need 3.10… Add pyenv or something similar as step 0:)
- mgraupner 4y agoPerfect explanation. Not much more to do for almost every project.
- mr_mitm 4y agoVirtual environments are rarely necessary in my experience. I just install everything in my home directory (the default when running `pip` as a regular user) and I haven't had a version conflict in ages.
- PaulHoule 4y agoIf I were hiring for a Python job the most important questions I would ask be around weeding somebody with this attitude out. If you are coding a little bit on your own account you can get away with this but if you are on a team you are playing to help the other team win if you think this way.
- mr_mitm 4y agoThat's harsh. I just want to point out that you don't have to go for venvs by default. I believe that's one of the reasons why people who aren't familiar with it are having issues with Python's package management. They think they always have to setup a venv even if there are no conflicts, and then things become quickly complicated. If you do run into conflicts (which, again, I believe to be rarer than a uninitiated user might think) I'm happy to point you to one of several solutions. I like pipx, but peotry or the built-in venv work as well.
- PaulHoule 4y agoRemember those platforms in Super Mario World that would start out with a number on them, say 5 and the number would count down each time you jumped off the platform? Each time you install something that isn’t conflicting now you increase the odds of a conflict the next time. Worse yet, you aren’t going to get that says ‘you have a conflict’ rather you are going to get some random error which is irreproducible so you won’t get help when you go to stack overflow or wherever you go to get bad advice. It is cruel to give beginners instructions which might work but are nearly certain to break their environment if they go at it long enough. Probably the best thing you could do to make Python easier to use is lock down all the footguns like ‘pip —user’ and pip outside of a virtualenv, ability to configure a charset, etc. You don’t argue about plugging a keyboard or mouse into a computer or getting a cell phone plan for your phone, if Python didn’t give you so many footguns you wouldn’t be complaining about how hard it is not to shoot yourself.
- mr_mitm 4y agoThat's all good and well, but how come I don't experience conflicts? I install a lot of packages all the time. In my experience, it's not that big of an issue and all I wanted to do was provide an additional data point. Plus, all of the advocates of using plain venv miss OP's point: it doesn't add an executable to their PATH. So much for giving cruel advice. There are many packages that I want to use system wide (or at least in every shell), like powerline in vim. Having to activate each environment manually before running an executable does not scale at all. Recommending venv outside of wrappers like pipx or peotry won't help with that. And that's my point: Before adding needless complexity, just try `pip install X`. If doesn't work, you can always fall back to pipx/poetry/etc.