Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tool
If you use the Anaconda python distribution, you can use the conda list command to see what was installed by what method:
user@pc:~ $ conda list
# packages in environment at /anaconda3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py36h2fc01ae_0
alabaster 0.7.10 py36h174008c_0
amqp 2.2.2
anaconda 5.1.0 py36_2
anaconda-client 1.6.9 py36_0
To grab the entries installed by pip (including possibly pip itself):
user@pc:~ $ conda list | grep \
astroid 1.6.2
billiard 3.5.0.3
blinker 1.4
ez-setup 0.9
feedgenerator 1.9
Of course you probably want to just select the first column, which you can do with (excluding pip if needed):
user@pc:~ $ conda list | awk '$3 ~ /pip/ {if ($1 != "pip") print $1}'
amqp
astroid
billiard
blinker
ez-setup
feedgenerator
Finally you can grab these values and pip uninstall all of them using the following:
user@pc:~ $ conda list | awk '$3 ~ /pip/ {if ($1 != "pip") print $1}' | xargs pip uninstall -y
Note the use of the -y flag for the pip uninstall to avoid having to give confirmation to delete.