Linux – Removing old files left by attempted pip installation

installationlinuxpipUbuntu

I'm installing a package through pip, but it fails due to lack of space (IOError: [Errno 28] No space left on device). The only filesystem with lack of space is /dev/sda2. I don't quite understand why it's full or what files are on it, but I purged old kernels to make more space. Apparently it was not enough free space as when I tried to install the package again, it failed.

After the attempted installation less space was available, which makes me think that some files from the attempted installation must still remain in a pip directory. How do I remove these files that are left behind by an attempted installation?

Also removing other unused files in pip directorys would be great. I'm on Linux 14.04.

Best Answer

In general, pip installs packages in one of the /usr/lib/<python-version>/site-packages/ or /usr/local/lib/<python-version>/dist-packages/ (or lib64 instead of lib) directories (for Ubuntu it should be the second one, I'm guessing that by saying "Linux 14.04" you meant that), and using /tmp or /var/tmp (again, based on your distro) for building packages.

However, pip doesn't have any support for removing files after partial installation, so you need to delete any leftovers manually. Check for pip builds in the temporary directories (you should be able to remove them safely if they are present).

For the actual files from the installation, you can try running pip uninstall <package-name> in hope it catches your partial installations as well (you can use this to remove any package installed via pip). Otherwise, you need to find the relevant files and remove them manually - use something like ls <directory-path> | grep <package-name> to locate them. Note that for the actual removal with rm command, you may need the root access.

It is also possible that the installation added system commands - check for /bin, /usr/bin, /usr/local/bin and other directories and proceed similar to previous point.

Related Question