== Some notes on upgrading programs with Python's pip My primary use of Python's pip package manager is to install programs like [[the Python LSP server PythonPylspNotes]]; I may install these into either a contained environment (a virtual environment or [[a PyPy one PyPyEasyHandInstall]]) or as a user package with '_pip install --user_'. In either case, the day will come when there's a new version of the Python LSP server (or whatever) and I want to update to it. As I noted down back in [[my pip cheatsheet PipCheatsheetForMe]], the basic command I want here is '_pip install --upgrade _', possibly with '_--user_' as well. However, it turns out that there are some complexities and issues here, which ultimately come about because [[pip is not the same sort of package manager as Fedora's DNF or Debian's apt ../tech/PackageManagersTwoTypes]]. The conventional way a Unix package manager such as DNF operates is that when you ask it to upgrade things, it upgrades everything that has new versions available. Pip doesn't behave this way. By default, it only upgrades the package that you asked it to, and doesn't upgrades any dependencies unless what you currently have doesn't satisfy the requirements of the new version of the upgraded package. Over enough time, this will often give you significantly out of date dependencies where you're missing out on improvements and bug fixes they've made even if your main package is theoretically fine with the old versions you have installed. (This generally also means that the versions you've wound up with don't match what you'd get if you deleted everything and reinstalled from scratch, assuming [[you kept track of what top level packages you installed TrackingPipInstalls]].) This can be controlled (to some degree) by [[the _--upgrade-strategy_ option to '_pip install_' https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-upgrade-strategy]]. This can be used to switch pip to an "eager" upgrade strategy, where it also upgrades dependencies to the latest available version that satisfies the requirements. You can set this as a default through [[pip's configuration files https://pip.pypa.io/en/stable/topics/configuration/]]. However, this eager upgrading process is not flawless (as pip error messages may occasionally point out); you may wind up with versions of dependencies that satisfy the program, but not other things you have sitting around (including as globally installed modules from your operating system). Despite this, I've set up a _~/.config/pip/pip.conf_ to make the eager mode my default, because it's more like how I want package management for programs to work; normally I want to be using the latest and best version of everything. (Usefully, you can tell if your pip.conf is working by what '_pip install --help_' reports as the default for _--upgrade-strategy_.) A Unix package manager like apt (almost) always removes the older version of a package when you upgrade to a newer one, and in fact many Unix packages can't have multiple versions installed at once. Pip somewhat apes this, but under some circumstances you can apparently wind up with older versions still present on disk. This especially matters if you decide to uninstall a package, because '_pip uninstall_' seems to only remove the most recent version (what '_pip list_' will show you as the version). If pip has left multiple versions sitting around, you may need a number of '_pip uninstall_' invocations to get the package gone from '_pip list_'. Alternatively, you can go to the appropriate location (such as '_~/.local/lib/python3.X/site-packages_') and manually remove all of the directories.