pip how to remove incorrectly installed package with a leading dash: “-pkgname”

It is safe to delete the offending folder(s) from your site-packages directory.

More info below (source):

When uninstalling a package, pip will now rename it in place to a name
that cannot be imported, and once it has confirmed that everything
will succeed (including installing new versions if it’s doing an
upgrade), only then will it delete those folders. If something fails,
it renames them back.

Previously, it would copy the entire contents to another directory,
and potentially another drive, and then copy them back if it needed.
So this change is a significant performance improvement, especially
for packages with a lot of files in them.

What you’re seeing here is that the deletion failed for some reason –
perhaps pip crashed? – and so the directories were not removed. I
thought pip ignored them completely, but perhaps something else
changed since I tested that?

The directories are safe to delete.

Leave a Comment