r/programminghorror • • Jan 12 '22

Python environment

https://imgs.xkcd.com/comics/python_environment.png

[removed] — view removed post

1.4k Upvotes

101 comments sorted by

View all comments

124

u/Instatetragrammaton Jan 12 '22 edited Jan 12 '22

How did it get to this? Furthermore - is just throwing each of these in a Docker container a viable solution?

Kind of strange for a language that has "there should be one— and preferably only one —obvious way to do it" as a design philosophy.

60

u/PostFunktionalist Jan 12 '22

The best practice is to make a new Python environment for every project using virtualenv or some convenience wrapper around it.

There are at least 4 different wrappers.

Good shit.

6

u/Yelov Jan 12 '22

I'm using conda for having multiple Python environments. How does using virtualenv for every project work? Eg if you have multiple projects with very similar packages, do you have to have them installed X times for every project? Or is there like a central package location that gets shared?

4

u/DrMaxwellEdison Jan 12 '22

Each environment is completely separate from each other, with no shared packages. That may seem like overkill, but supposing two projects rely on the same package and you start upgrading one of them, you don't inadvertently update and potentially break the other.