Skip to content

Instantly share code, notes, and snippets.

@kirshiyin89
Last active June 17, 2021 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirshiyin89/bfce68121fbd4b5f3ea73c57e68d9957 to your computer and use it in GitHub Desktop.
Save kirshiyin89/bfce68121fbd4b5f3ea73c57e68d9957 to your computer and use it in GitHub Desktop.
Uninstall python packages in PyWebIO GUI
from pywebio.output import *
from pywebio.input import *
from pip import _internal
from pip._internal.utils.misc import get_installed_distributions
import time
put_markdown('Pip Package Manager')
installed_packages = get_installed_distributions()
installed_packages_set = { package for package in ["%s==%s" % (i.key, i.version)
for i in installed_packages] }
package = select("Choose a package to uninstall", sorted(installed_packages_set))
print("you chose to remove", package)
_internal.main(['uninstall', '-y', package])
put_text(f"Uninstalling {package}. Please wait until it is removed!")
put_processbar('bar')
for i in range(1, 11):
set_processbar('bar', i / 10)
time.sleep(0.05)
put_markdown(f"Successfully uninstalled {package}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment