A cheatsheet for Python's pip for how I use it

May 24, 2020

To save me having to look up or try to remember the various pip arguments and usage the next time I need to do something like update the pyls Python LSP server, here is a cheatsheet for how I use pip.

First, I always use pip with a 'user' install (the --user argument), which installs things in $HOME/.local. On my machines, pip puts binaries in .local/bin and installed Python packages in .local/lib/pythonX.Y; some might appear in .local/libexec if they had compiled portions, but I'm not sure. This is also where running a setup.py with --user puts things, which is unsurprising (I install Django test versions this way).

To install something, the basic usage is 'pip install --user <package>'. Once packages are installed, I can check for what packages have updates available with 'pip list --user --outdated'. To update a package, it's 'pip install --user --upgrade <package>'. I'm not sure what happens if you leave out the --upgrade.

(Plain 'pip list --user' lists what you have installed and leaves out checking for updates.)

Now that I've looked it up, removing a package is done with 'pip uninstall <package>'. There is 'pip check' to see if all your dependencies are fine, but this has potentially confusing output because it has no '--user' argument and so apparently checks both your packages and the system installed packages; on Ubuntu, the system packages may not have dependencies that 'pip check' is happy with. Similarly, 'pip uninstall' has no --user argument and will happily try to remove system packages instead of your own packages. Also, I don't think removing packages warns you about breaking dependencies.

Really there isn't much to my pip usage and I probably don't normally need a cheatsheet. But sometimes I don't deal with this level of Python stuff for long enough that it starts dropping out of my memory.

(So far, my only use of pip is to keep python-language-server up to date, and I don't necessarily remember to check and update it on a regular basis.)

Written on 24 May 2020.
« Security questions and warnings are effectively confirmation requests
My failure with Xpra (probably because what I want is almost impossible) »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun May 24 21:11:41 2020
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.