Skip to content

Commit e949fe6

Browse files
Update pipwizard.py
1 parent abe9dee commit e949fe6

File tree

1 file changed

+49
-35
lines changed

1 file changed

+49
-35
lines changed

pipwizard.py

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,59 @@
99
os.system("cls")
1010
print()
1111
print(" " + Fore.BLACK + Back.YELLOW + " PIPWIZARD - Package Installer ")
12-
print(Fore.LIGHTBLACK_EX + " Copyright © 2023 Ashfaaq Rifath - PipWizard v1.2.0")
12+
print(Fore.LIGHTBLACK_EX + " Copyright © 2023 Ashfaaq Rifath - PipWizard v1.3.0")
1313
print('''
14-
(1) Install library
15-
(2) Upgrade library
16-
(3) Uninstall library''')
17-
option = input(Fore.CYAN + " Enter option: " + Style.RESET_ALL)
14+
(1) Install package
15+
(2) Upgrade package
16+
(3) Uninstall package''')
1817

19-
if option == "1":
20-
print()
21-
install_lib = input(Fore.CYAN + " Enter library name: " + Style.RESET_ALL)
22-
try:
23-
importlib.import_module(install_lib)
24-
print(" " + Fore.BLACK + Back.GREEN + f" {install_lib} already installed ")
18+
while True:
19+
option = input(Fore.CYAN + " Enter option: " + Style.RESET_ALL)
20+
if option == "1":
2521
print()
26-
input("Press Enter to exit...")
27-
except ImportError:
28-
subprocess.check_call(["pip", "install", install_lib])
29-
print(" " + Fore.BLACK + Back.GREEN + f" {install_lib} has been installed ")
30-
print()
31-
input("Press Enter to exit...")
22+
install_pkg = input(Fore.CYAN + " Enter package name: " + Style.RESET_ALL)
3223

33-
elif option == "2":
34-
print()
35-
upgrade_lib = input(Fore.YELLOW + " Enter library name: " + Style.RESET_ALL)
24+
try:
25+
importlib.import_module(install_pkg)
26+
print(" " + Fore.BLACK + Back.GREEN + f" {install_pkg} already installed ")
27+
print()
28+
input("Press Enter to exit...")
29+
except ImportError:
30+
subprocess.check_call(["pip", "install", install_pkg])
31+
print(" " + Fore.BLACK + Back.GREEN + f" Installed {install_pkg} ")
32+
print()
33+
input("Press Enter to exit...")
34+
break
3635

37-
subprocess.check_call(["pip", "install", "--upgrade", upgrade_lib])
38-
print(" " + Fore.BLACK + Back.GREEN + f" {upgrade_lib} has been upgraded ")
39-
print()
40-
input("Press Enter to exit...")
36+
elif option == "2":
37+
print()
38+
upgrade_pkg = input(Fore.YELLOW + " Enter package name: " + Style.RESET_ALL)
4139

42-
elif option == "3":
43-
print()
44-
uninstall_lib = input(Fore.LIGHTRED_EX + " Enter library name: " + Style.RESET_ALL)
40+
try:
41+
subprocess.check_call(["pip", "install", "--upgrade", upgrade_pkg])
42+
print(" " + Fore.BLACK + Back.GREEN + f" Upgraded {upgrade_pkg} ")
43+
print()
44+
input("Press Enter to exit...")
45+
except subprocess.CalledProcessError:
46+
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
47+
print()
48+
input("Press Enter to exit...")
49+
break
4550

46-
subprocess.check_call(["pip", "uninstall", uninstall_lib])
47-
print(" " + Fore.BLACK + Back.RED + f"{uninstall_lib} has been uninstalled ")
48-
print()
49-
input("Press Enter to exit...")
50-
else:
51-
print(" " + Fore.BLACK + Back.RED + " INVALID OPTION ")
52-
print()
53-
input("Press Enter to exit...")
51+
elif option == "3":
52+
print()
53+
uninstall_pkg = input(Fore.LIGHTRED_EX + " Enter package name: " + Style.RESET_ALL)
54+
55+
try:
56+
subprocess.check_call(["pip", "uninstall", uninstall_pkg])
57+
print(" " + Fore.BLACK + Back.RED + f" Unistalled {uninstall_pkg} ")
58+
print()
59+
input("Press Enter to exit...")
60+
except subprocess.CalledProcessError:
61+
print(" " + Fore.BLACK + Back.RED + " PACKAGE NOT FOUND ")
62+
print()
63+
input("Press Enter to exit...")
64+
break
65+
else:
66+
print(" " + Fore.BLACK + Back.RED + " INVALID OPTION ")
67+
print()

0 commit comments

Comments
 (0)