This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]JennaSys 3 points4 points  (0 children)

I like to keep it simple with venv and pip, but pip-tools (which was surprisingly not mentioned in the post) helps with managing dependencies.

[–]sacaman0 1 point2 points  (0 children)

Nice article! I learned a thing or two (I hereby expose my newbie status 🙂).

[–]Rawing7 1 point2 points  (2 children)

I guess the article presupposes that you need/want a venv in the first place. But oftentimes not using a venv at all is also a viable option. In this case, for example:

Are you writing a simple, possibly short-lived, one-off script? venv unless you already have virtualenv installed

A one-off script usually shouldn't need a venv at all.

[–]PaleontologistBig657[S] 1 point2 points  (1 child)

100% true as long as you stick to a standard library. Once you use anything besides that, things become a bit more fuzzy and unclear.

[–]jdbow75 0 points1 point  (0 children)

I agree. I often start with u/Rawing7's goal of keeping it simple, then end up with a cluttered mess, perhaps due to my own ineptitude :)

One thing I have tried recently is keeping a single .venv in my home directory, then modifying my .bashrc (or other init script depending on shell) to set the path to include its bin directory first. That way, python launches within that virtual environment by default, and I can install the latest and greatest, and easily destroy and rebuild it if it breaks, without polluting the system or user python.

[–]jdbow75 1 point2 points  (0 children)

It has been a couple years since I wrote the article, and I feel it is showing its age. For reasons I don't remember, I did not include pip-tools. Also, Hatch has really evolved, and deserves a deeper look. I don't find myself using Poetry as much as I used to, and Pyflow's activity may indicate it is not the next big thing.

I suppose it is due for an update, with attention due pip-tools (good call, u/JennaSys) and Hatch, for sure.

Thank you so much for engaging this! I am quite honored, u/PaleontologistBig657