In newer versions (> 1.x) there is pip.operation.freeze:
try:
from pip._internal.operations import freeze
except ImportError:
from pip.operations import freeze
x = freeze.freeze()
for p in x:
print p
The output is as expected:
AMQP == 1.4.6
anyjson == 0.3.3
== 3.3.0.20
defusedxml == 0.4.1
== 1.8.1
-picklefield == 0.3.1
Docutils == 0,12
... .