Skip to content

Commit 626079d

Browse files
Update pipwizard.py
1 parent 28ea56a commit 626079d

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

pipwizard.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
import importlib
22
import subprocess
33

4-
def install_lib (pkg):
4+
print('''
5+
(1) Install library
6+
(2) Upgrade library
7+
(3) Uninstall library''')
8+
option = input("Enter opton: ")
9+
10+
if option == "1":
11+
print()
12+
install_lib = input("Enter library name: ")
13+
514
try:
6-
importlib.import_module(pkg)
7-
print(f"{pkg} is already installed")
15+
importlib.import_module(install_lib)
16+
print(f"{install_lib} is already installed")
817
except ImportError:
9-
subprocess.check_call(["pip", "install", pkg])
10-
print(f"{pkg} had been installed.")
18+
subprocess.check_call(["pip", "install", install_lib])
19+
print(f"{install_lib} had been installed.")
20+
21+
elif option == "2":
22+
upgrade_lib = input("Enter library name: ")
23+
24+
subprocess.check_call(["pip", "install", "--upgrade", upgrade_lib])
25+
print(f"{upgrade_lib} has been upgraded.")
26+
27+
elif option == "3":
28+
uninstall_lib = input("Enter library name: ")
1129

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

0 commit comments

Comments
 (0)