      """ Get currently installed packages """
      global INSTALLED_PACKAGES
      chk = Popen("{} -m pip freeze".format(sys.executable),
                  shell=True, stdout=PIPE)
      installed = chk.communicate()[0].decode().splitlines()
      for pkg in installed:
          item = pkg.split("==")
          INSTALLED_PACKAGES[item[0]] = item[1]
  
  
 
</s> remove     stdout = stdout.decode()
 </s> add     stdout = stdout.decode(ENCODING) </s> remove              for line in stdout.decode().splitlines()
 </s> add              for line in stdout.decode(ENCODING).splitlines() </s> remove              for line in stdout.decode().splitlines()
 </s> add              for line in stdout.decode(ENCODING).splitlines() </s> remove            for line in stdout.decode().splitlines()
 </s> add            for line in stdout.decode(ENCODING).splitlines() </s> remove            for line in stdout.decode().splitlines()
 </s> add            for line in stdout.decode(ENCODING).splitlines()
    installed = chk.communicate()[0].decode(ENCODING).splitlines()
      """ Get currently installed packages """
      global INSTALLED_PACKAGES
      chk = Popen("{} -m pip freeze".format(sys.executable),
                  shell=True, stdout=PIPE)
    installed = chk.communicate()[0].decode(ENCODING).splitlines()
      for pkg in installed:
          item = pkg.split("==")
          INSTALLED_PACKAGES[item[0]] = item[1]
  
  
keep keep keep keep replace keep keep keep keep keep
 setup.py - Get system encoding 
setup.py