File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change 1
1
import importlib
2
2
import subprocess
3
3
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
+
5
14
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" )
8
17
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: " )
11
29
12
- install_lib ("pyperclip" )
30
+ subprocess .check_call (["pip" , "uninstall" , uninstall_lib ])
31
+ print (f"{ uninstall_lib } had been uninstalled." )
You can’t perform that action at this time.
0 commit comments