Sometimes I want to uninstall an injected package: for instance, the latest release of tox means that detox is no longer required/supported.
Is there a way to do this?
pipx uninject tox detox
I wonder what the best name for that should be. exclude, expel and withdraw are all cute.
In the meantime, you can do $HOME/.local/pipx/<x>/bin/pip uninstall <y>, but that's a bit messy.
The runpip command was added in 0.13 which can indirectly do this. Therefore I will close this issue since runpip is a decent workaround.
For the record, here's how to do that with runpip (since this issue thread came up first for me in a Google search):
pipx runpip name-of-my-environment uninstall name-of-package
I don't personally use pipx inject and was against it initially, but it's proven quite popular. I closed the issue pretty quickly because I'm biased, but I actually think pipx uninject might not be a bad idea. Reopening in case anyone else has thoughts on this.
:+1: for uninject
Let鈥檚 make uninject happen
I'd like uninject.
One caveat about uninject is it won鈥檛 uninstall dependencies of the injected package, since pip does not know how to do that. But that鈥檚 quite well-known at this point anyway so I don鈥檛 think it鈥檚 a blocker, just something to keep in mind that less-experienced users may have false hopes on.
Does pipx maintain a listed of injected packages in the metadata? We may be able to reconstruct the environment an clean up unneeded packages automatically as well.
That's a good point @uranusjr . The metadata indeed contains the main package and a list of all injected packages. It does not keep track of any incidentally-installed dependencies.
To find any dependencies to remove, we could
pip list --not-required to find all packages that are not depended upon--not-required list, remove the current main package and injected packages--not-required packagesI suppose one risk of the above is if the user did something more "manual" like using a runpip command to install something that we can't keep track of in the metadata.
Another approach would be to make the clean-up behaviour explicit to the user, a la apt autoremove. pipx uninject only uninstalls the injected package by default, not its dependencies, but shows a messages listing seemingly unneeded packages in the environment, promping the user to run pipx clean to uninstall them. uninject can also have a --clean flag that does this automatically, like apt remove --auto-remove.
Another approach would be to make the clean-up behaviour explicit to the user, _a la_
apt autoremove.pipx uninjectonly uninstalls the injected package by default, not its dependencies, but shows a messages listing seemingly unneeded packages in the environment, promping the user to runpipx cleanto uninstall them.uninjectcan also have a--cleanflag that does this automatically, likeapt remove --auto-remove.
Agreed, I like this
Most helpful comment
For the record, here's how to do that with
runpip(since this issue thread came up first for me in a Google search):