-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install_Modules.py
56 lines (45 loc) · 1.43 KB
/
Install_Modules.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import subprocess
import os
import platform
import bpy
def isWindows():
return os.name == 'nt'
def isMacOS():
return os.name == 'posix' and platform.system() == "Darwin"
def isLinux():
return os.name == 'posix' and platform.system() == "Linux"
def python_exec():
if isWindows():
return os.path.join('C:\\Program Files\\Blender Foundation\\Blender 3.6\\3.6\\python', 'bin', 'python.exe')
elif isMacOS():
try:
# 2.92 and older
path = bpy.app.binary_path_python
except AttributeError:
# 2.93 and later
import sys
path = sys.executable
return os.path.abspath(path)
elif isLinux():
import sys
return os.path.join('C:\\Program Files\\Blender Foundation\\Blender 3.6\\3.6\\python', 'bin', 'python')
else:
print("sorry, still not implemented for ", os.name, " - ", platform.system)
def installModule(packageName):
try:
subprocess.call([python_exe, "import ", packageName])
except:
python_exe = python_exec()
# upgrade pip
subprocess.call([python_exe, "-m", "ensurepip"])
subprocess.call([python_exe, "-m", "pip", "install", "--upgrade", "pip"])
# install required packages
subprocess.call([python_exe, "-m", "pip", "install", packageName])
installModule("openmesh")
# INSTALLED MODULES:
# numpy
# openmesh
# pandas
# scipy
# tripy