you don't need this, just do pip freeze > packages.txt
to take a backup of pip packages and when you want to restore just do pip install -r packages.txt
, it's so simple.
Scripts for taking a backup of the list of all Installed pip packages and restoring them