I recently used the ast module to find imports to see which lines in &quot;pip freeze&quot;  are actually necessary for any given file&#x2F;directory.  It was pretty neat, and I hope I have a reason to use it again.