Reputation: 2575
To add a question to the great question and discussion here on pyenv, venv, virtualenv, and virtualenvwrapper, could someone please explain how conda environments fit into this world? When are the preferred use cases for conda environments vs the other virtual environment options?
Update to question in November 2024: how do Poetry and Docker fit into this world?
Upvotes: 24
Views: 31177
Reputation: 2575
Here is how everything fits together. We'll start with the problems the various tools are solving. Then cover how each tool slots in.
Dependency Managers. Problem these tools solve:
Dependency/Package Managers solve the above questions for us.
Environment Managers. Problems these solve:
Environment managers create and manage "virtual environments", which allow each project to have its own set of packages/python versions installed.
How do all the tools fit in? Some confusion is often caused by overlap in the tooling. Here is how they map:
How does Docker fit in? Docker provides environment and dependency management, and also provides operating system management. For example, a Docker container can allow one project to operate on a Fedora Linux distribution, and another project to use Ubuntu. Docker can also be mixed and matched with the above tools, e.g. Docker handles the operating system management, but calls Poetry to handle environment and dependency management. Docker can also manage other dependencies too, like network settings, system libraries, etc.
When to Use What?
Hope this helps everyone save a bunch of time understanding how all these tools fit together.
Upvotes: 43
Reputation: 166
You can also use (mini)conda to install not just different python versions (into different environments), but node.js, ruby, even postgresql, etc. It has more binary-compiled packages than venv (well, so-called wheels), You can definitely use it instead of pyenv and nvm and rvm, etc. The linked article to whiteboxml is really good in pinning down the differences.
I also tried it on windows extensively, and have to admit it works better than I thought. If something does not work out you can always use WSL2 or just switch to macos/linux.
Upvotes: 0