-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequirementsUpdater.py
More file actions
27 lines (22 loc) · 862 Bytes
/
RequirementsUpdater.py
File metadata and controls
27 lines (22 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
import shutil
import pkg_resources
def checkAndInstall():
packages = ["beautifulsoup4", "pyperclip", "customtkinter"]
if not shutil.which("pip"):
print("Error: 'pip' is not installed.")
return
for package in packages:
try:
if package not in pkg_resources.working_set.by_key:
print(f"Installing {package}")
subprocess.check_call([shutil.which("pip"), "install", package])
else:
print(f"{package} is up-to-date.")
except subprocess.CalledProcessError as e:
print("Error: Command failed with the following error:")
print(f"Command: {' '.join(e.cmd)}")
print("Error Output:\n", e.stderr)
except Exception as e:
print(f"Unexpected Error: {str(e)}")
# checkAndInstall()