3

I installed a few user packages with pip by using

pip3 install --user <package_name>

I did this on a machine running Ubuntu 17.10.

I would like to start afresh. Is it safe to delete ~/.local/bin in order to do so or is there some other, more elegant solution? In particular, I'm worrying about messing with the Python packages, which my system requires to function properly.

mamr
  • 63
  • 5
  • `pip uninstall` – metatoaster May 31 '18 at 04:52
  • 1
    Possible duplicate of [What is the easiest way to remove all packages installed by pip?](https://stackoverflow.com/questions/11248073/what-is-the-easiest-way-to-remove-all-packages-installed-by-pip) – phd May 31 '18 at 07:07

2 Answers2

2

The Free Desktop Specification notes that ~/.local/bin is a general place for user binaries, so I don't think its safe to assume that deleting that wont affect anything else.

The best method would be to use pip3 uninstall --user <package> to remove specific packages. you can list installed packages with pip3 list --user

Edit: A one-liner to delete all pip3 installed packages, using pip3's uninstall method and jq:

pip3 list --user --format=json | jq '.[].name' | xargs -I{} pip3 uninstall --user {}

Be careful though, as it will delete everything user installed, whether you use it or not!

ThePengwin
  • 822
  • 7
  • 10
  • 2
    A simpler version: `pip3 list --user --format=freeze | xargs pip3 uninstall --user -y`. – hoefling May 31 '18 at 08:45
  • [pip uninstall](https://pip.pypa.io/en/stable/reference/pip_uninstall/) according to this, we may update this command to `pip3 list --user --format=freeze | xargs pip3 uninstall -y` – Choi Apr 22 '20 at 10:35
0

You should uninstall package manually:

pip uninstall package_name