I am updating all my packages with pip with
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
but it takes forever since many more packages are installed than I actually need.
Can I delete all unused packages with pip?
Of course you can delete any package you want. The real question is should you?
Is this in a virtualenv or is it system wide python? If it's system wide, just because your project isn't using those packages doesn't mean no other apps rely on them. If its a virtualenv, I would recommend creating a temp virtualenv, and installing only the packages that you know your project depends on. This way you can see which packages were installed as dependencies of packages you require and you can remove the ones that are not needed anymore.