The two main approaches I’ve seen for installing applications written
in python that aren’t packaged by your system package manager are
pip install --user and
but I use a slightly different approach that I want to share.
My goals are:
- Don’t pollute the global python environment (doing
pip install --userdoes this for your user)
- Be relatively efficient (
pipxis mostly fine, but it does create a virtual python environment for each application, which seems a little unnecessary)
- It should be understandable (to me, at least)
- It should work (obviously)
Given these requirements, I came up with a scheme to install the applications in a single virtual environment and then symlink them into my path. This can fail #4 above (and not work) in cases where an application has overly specific or odd requirements that conflict, but I don’t currently run into that issue.
Here’s how it works. First, I make a virtual environment inside
Then, I install the packages (I actually track their versions using the techniques outlined in the post about repeatable builds with pip, but here I’m just showing installing whatever the latest versions are):
Finally, I symlink the packages from the virtual environment into my path:
This installs the applications into my path without actually installing the packages into any globally available python location. I can easily use the same technique to install packages with different version of python or with conflicting version requirements by making more virtual environments.