Search code examples
piphomebrewpyenv

Keeping environments organized when using pyenv, pip, and Homebrew


My goal is pretty simple: to do a pip install of some software.

I already use pyenv and Homebrew, but haven't much lately. I don't remember all the details as clearly now. And it's also likely my understanding is not as complete as I previously believed.

Today I realized that I don't understand the encapsulation hierarchy or interplay between the three:

Homebrew / pyenv / pip

I thought doing brew install or pip install would install the software inside of my current pyenv environment. But as I'm looking at tutorials, I realize that pyenv itself was installed by means of brew install, so clearly there are gaps in my understanding of the structure of this whole organizational system.

Can somebody please ELI5, maybe with a visual sketch (I learn best visually), how this is all supposed to be structured in order to work correctly? I want to keep the environments separated and functioning correctly.

Sorry if this is pretty basic for some people, but I want to be sure I finally understand rather than fumbling forward on assumption, as I add more and more software.


Solution

    • homebrew - is a package manager (basically for macOS, because it didn't have one, so some smart people filled that void) there is also a version for linux, called linuxbrew. It is needed to install\remove programs in a automated and consistent manner.

    • pyenv is a program, helper tool you name it. Which was designed to help manage multiple python installations on the same computer. There are multiple options to install pyenv, one of them is via homebrew.

    • pip is a package installer for python. It is being used by python to install python packages. Guess what, pip is a python module by itself. You can invoke it like this python -m pip

    I think what you meant by pyenv is actually a venv another python module, that allows to install pip packages locally. So you'll be able to have multiple versions of same package installed in different projects on same computer.

    Bottomline

    homebrew is for installing any piece of software that exists in their repos.

    pyenv is a tool to manage python installations.

    pip manages python packages. It is usually bundled with python installation. BTW there are alternatives to pip, one of them is poetry