forked from TREE-Ind/Blender-GPT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdependencies.py
30 lines (26 loc) · 936 Bytes
/
dependencies.py
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
28
29
30
import subprocess
import sys
import bpy
def install_package(package):
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
return False
return True
def check_and_install_dependencies():
packages = ["openai", "numpy"]
installed = True
for package in packages:
try:
__import__(package)
except ImportError:
print(f"Installing {package}...")
success = install_package(package)
if success:
print(f"{package} installed successfully.")
else:
installed = False
print(f"Failed to install {package}.")
if not installed:
bpy.ops.ui.show_message_box(message="Some dependencies failed to install. Check the Blender console for details.")