-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28ea56a
commit 626079d
Showing
1 changed file
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |