[Script] Restore Python Packages Uninterrupted
#1
I cycles through distros a lot and make regular backups of my data and Python packages among other things. If you make a backup of your packages with the:
Code:
pip3 freeze | tee -a requirements.txt
Command, you have a convenient text file with everything you need on that front. However, oftentimes when i go to install the packages on my new distro or restore a backup, one package has been deprecated or isn't installing properly for one reason or another. And when that happens `pip` stops processing your list.

Since it's real annoying when that happens i wrote the below script as a quick and simple solution.

Code:
#!/usr/bin/env python3
#____  ____            __               
#\  \ /  /____  _____/  |_  ___________ 
# \  Y  // __ \_/ ___\  __\/  _ \_  __ \
#  \    /\  ___/\  \___|  | (  <_> )  | \/
#  \___/  \___  >\___  >__|  \____/|__|   
#              \/    \/             
#--Licensed under GNU GPL 3
#----Authored by Vector/NullArray
##############################################
import os

def main(location):
    strarray = []

    if not os.path.isfile(location):
        print("Could not find file")
    else:
        with open(location, 'r') as infile:
            for str in infile:
                strarray.append(str)

    for line in strarray:
        x = "pip3 install " + line
        try:
            os.system(x)
        except:
            pass
        finally:
            continue


if __name__ == "__main__":
    os.system('clear')
    print("Install a 'pip3 freeze' backup package list without interuptions.")
    print("Simply enter the location to your text file below.")
    location = input("\nPath: ")
    main(location)
    print("\nDone!")

Figured i'd share it here in case it might be helpful to some of you as well.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Python 3] Obfuscation Challenge Abracadabra 2 1,311 06-17-2020, 02:56 AM
Last Post: DeepLogic
  Python Ebook Collection [89 Files] Insider 14 27,853 01-18-2019, 04:27 PM
Last Post: Insider
  how to code TCP in python? QMark 10 10,082 09-24-2018, 03:40 PM
Last Post: ekultek
  my plan to learn python programming for hacking, networking, and web dev QMark 6 9,169 02-22-2018, 09:26 PM
Last Post: QMark