Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip: Uninstalling package from specific directory

Tags:

I installed package into specific local directory using pip install -t <dir>.

Now I want to uninstall it, but I cannot find a way to uninstall from that specific directory. For uninstall there is no valid option -t | --target, which exists for install command.

like image 575
Denis Itskovich Avatar asked Jul 06 '15 03:07

Denis Itskovich


People also ask

How do I remove a specific directory in pip?

pip does not keep hidden directories of installed packages and scans directories such as /usr/local/lib/python2. 7/dist-packages directly to determine what is installed. To uninstall it, just go into localpips and delete the files and directories that were created.

What is the easiest way to remove all packages installed by pip?

To remove all packages installed by pip with Python, we run pip uninstall . to run pip freeze to get the list of packages installed. And then we pipe that to xargs pip uninstall -y to remove all the packages listed by pip freeze with pip uninstall .

How do I uninstall a package without pip?

You have two options: Use another package manager such as conda . This will only work if the package was originally installed with that package manager. Delete the package manually with File Explorer or the command-line.


1 Answers

Remove them manually. pip does not keep hidden directories of installed packages and scans directories such as /usr/local/lib/python2.7/dist-packages directly to determine what is installed.

So, if you installed something using -t just go to the directory you specified and delete all traces, including any metadata files. For example,

$ mkdir localpips
$ pip install -t localpips docopt
Downloading/unpacking docopt
  Downloading docopt-0.6.2.tar.gz
  Running setup.py (path:/tmp/pip_build_garyw/docopt/setup.py) egg_info for package docopt

Installing collected packages: docopt
  Running setup.py install for docopt

Successfully installed docopt
Cleaning up...
$ cd localpips
$ ls -l
total 48
drwxr-xr-x 2 garyw garyw  4096 Jul  6 17:27 docopt-0.6.2.egg-info
-rw-r--r-- 1 garyw garyw 19946 Jul  6 17:27 docopt.py
-rw-r--r-- 1 garyw garyw 23326 Jul  6 17:27 docopt.pyc
$ 

To uninstall it, just go into localpips and delete the files and directories that were created.

I know, it's not that elegant, and sometimes you have no idea what may be related to what if you didn't observe the install carefully, but that's the way it is.

like image 139
Gary Wisniewski Avatar answered Oct 09 '22 10:10

Gary Wisniewski