-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathautoInstallDlib.py
More file actions
48 lines (39 loc) · 1.62 KB
/
Copy pathautoInstallDlib.py
File metadata and controls
48 lines (39 loc) · 1.62 KB
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
import sys
import subprocess
import platform
def install_dlib():
"""
Attempts to install Dlib using standard pip install first,
falling back to a specific wheel file if necessary.
"""
print('Attempting to install Dlib...')
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'dlib'])
print('Dlib installed successfully using standard pip install.')
return True
except subprocess.CalledProcessError as e:
print(f'Standard pip install failed: {e}')
versionA = platform.python_version().split('.')
version_str = f"{versionA[0]}{versionA[1]}"
wheel_url = f'https://github.com/sachadee/Dlib/raw/main/dlib-20.0.0-cp{version_str}-cp{version_str}-win_amd64.whl'
try:
print(f'Falling back to installing specific wheel: {wheel_url}')
subprocess.check_call([sys.executable, '-m', 'pip', 'install', wheel_url])
print('Dlib installed successfully using specific wheel file.')
return True
except subprocess.CalledProcessError as e:
print(f'Dlib installation failed using both methods: {e}')
return False
try:
import dlib
print(f'Dlib {dlib.__version__} already installed. Exiting script.')
sys.exit(0)
except ImportError:
print(f'Dlib not found locally.')
if install_dlib():
try:
import dlib
print(f'Verification: Dlib {dlib.__version__} is now available.')
except ImportError:
print('Verification failed. Dlib might require a new script execution.')
sys.exit(0)