Skip to content

Commit

Permalink
Update pipwizard.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfaaqrifath authored Apr 9, 2023
1 parent 28ea56a commit 626079d
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions pipwizard.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
import importlib
import subprocess

def install_lib (pkg):
print('''
(1) Install library
(2) Upgrade library
(3) Uninstall library''')
option = input("Enter opton: ")

if option == "1":
print()
install_lib = input("Enter library name: ")

try:
importlib.import_module(pkg)
print(f"{pkg} is already installed")
importlib.import_module(install_lib)
print(f"{install_lib} is already installed")
except ImportError:
subprocess.check_call(["pip", "install", pkg])
print(f"{pkg} had been installed.")
subprocess.check_call(["pip", "install", install_lib])
print(f"{install_lib} had been installed.")

elif option == "2":
upgrade_lib = input("Enter library name: ")

subprocess.check_call(["pip", "install", "--upgrade", upgrade_lib])
print(f"{upgrade_lib} has been upgraded.")

elif option == "3":
uninstall_lib = input("Enter library name: ")

install_lib("pyperclip")
subprocess.check_call(["pip", "uninstall", uninstall_lib])
print(f"{uninstall_lib} had been uninstalled.")

0 comments on commit 626079d

Please sign in to comment.