1
1
import os
2
+ import subprocess
2
3
import sys
3
4
from pprint import pprint
4
5
6
+ import pip
7
+
8
+ try :
9
+ from jupyter_client .kernelspec import KernelSpecManager , NoSuchKernel
10
+ except :
11
+ print (
12
+ "Importing Jupyter failed. Please follow the installation instructions "
13
+ "in the README in the same directory as this script or "
14
+ "at https://github.com/openvinotoolkit/openvino_notebooks."
15
+ )
16
+ sys .exit ()
17
+
18
+
19
+
20
+ def show_supported (supported ):
21
+ """
22
+ Returns OK (in green) if supported evaluates to True, otherwise NOT OK (in red).
23
+ """
24
+ try :
25
+ from colorama import Fore , Style , init
26
+
27
+ init ()
28
+ startcolor = Fore .GREEN if supported else Fore .RED
29
+ stopcolor = Style .RESET_ALL
30
+ except :
31
+ startcolor = stopcolor = ""
32
+ output = "OK" if supported else "NOT OK"
33
+ return f"{ startcolor } { output } { stopcolor } "
34
+
35
+
36
+ def pip_check ():
37
+ result = subprocess .check_output (["pip" , "check" ], universal_newlines = True )
38
+ if "No broken requirements found" in result :
39
+ return True , ""
40
+ else :
41
+ return False , result
42
+
43
+
44
+ def kernel_check ():
45
+ try :
46
+ kernel = KernelSpecManager ().get_kernel_spec ("openvino_env" )
47
+ except NoSuchKernel :
48
+ return False , ""
49
+ kernel_python = kernel .argv [0 ]
50
+ return True , kernel_python
51
+
52
+
5
53
PYTHON_EXECUTABLE = sys .executable
6
54
PYTHON_VERSION = sys .version_info
55
+ PIP_VERSION = pip .__version__
7
56
OS = sys .platform
57
+ KERNEL_INSTALLED , KERNEL_PYTHON = kernel_check ()
58
+ NO_BROKEN_REQUIREMENTS , PIP_CHECK_OUTPUT = pip_check ()
59
+
60
+ CORRECT_KERNEL_PYTHON = PYTHON_EXECUTABLE == KERNEL_PYTHON
8
61
9
62
IN_OPENVINO_ENV = "openvino_env" in sys .executable
10
63
SUPPORTED_PYTHON_VERSION = PYTHON_VERSION .major == 3 and (
11
64
PYTHON_VERSION .minor >= 6 and PYTHON_VERSION .minor <= 8
12
65
)
13
- GLOBAL_OPENVINO_INSTALLED = "openvino_202" in os .environ .get (
14
- "LD_LIBRARY_PATH" , ""
15
- ) + ":" .join (sys .path )
66
+ GLOBAL_OPENVINO_INSTALLED = "openvino_202" in os .environ .get ("LD_LIBRARY_PATH" , "" ) + ":" .join (
67
+ sys .path
68
+ )
69
+
16
70
17
71
try :
18
72
import openvino
30
84
31
85
try :
32
86
import mo_onnx
33
- import numpy
34
-
35
- NUMPY_VERSION = numpy .__version__
36
- SUPPORTED_NUMPY_VERSION = NUMPY_VERSION < "1.19"
37
87
except ImportError :
38
88
DEVTOOLS_INSTALLED = False
39
89
else :
40
90
DEVTOOLS_INSTALLED = True
41
91
42
92
43
- def show_supported (supported ):
44
- """
45
- Returns OK (in green) if supported evaluates to True, otherwise NOT OK (in red).
46
- """
47
- try :
48
- from colorama import Fore , Back , Style
49
- from colorama import init
50
-
51
- init ()
52
- startcolor = Fore .GREEN if supported else Fore .RED
53
- stopcolor = Style .RESET_ALL
54
- except :
55
- startcolor = stopcolor = ""
56
- output = "OK" if supported else "NOT OK"
57
- return f"{ startcolor } { output } { stopcolor } "
58
-
59
-
60
93
print ("System information:" )
61
94
print (f"Python executable: { PYTHON_EXECUTABLE } " )
95
+
96
+ print (f"Pip version: { PIP_VERSION } " )
62
97
print (f"OpenVINO environment activated: { show_supported (IN_OPENVINO_ENV )} " )
98
+ print (f"Jupyter kernel installed for openvino_env: { show_supported (KERNEL_INSTALLED )} " )
99
+ if KERNEL_INSTALLED :
100
+ print (f"Jupyter kernel Python executable: { KERNEL_PYTHON } " )
101
+ print (
102
+ "Jupyter kernel Python and OpenVINO environment Python match: "
103
+ f"{ show_supported (CORRECT_KERNEL_PYTHON )} "
104
+ )
63
105
print (
64
106
f"Python version: { PYTHON_VERSION .major } .{ PYTHON_VERSION .minor } "
65
107
f"{ show_supported (SUPPORTED_PYTHON_VERSION )} "
66
108
)
67
- print (
68
- f"OpenVINO pip package installed: { show_supported (PIP_OPENVINO_INSTALLED )} "
69
- )
109
+ print (f"OpenVINO pip package installed: { show_supported (PIP_OPENVINO_INSTALLED )} " )
70
110
print (f"OpenVINO import succeeds: { show_supported (OPENVINO_IMPORT )} " )
71
- print (
72
- f"OpenVINO development tools installed: { show_supported (DEVTOOLS_INSTALLED )} "
73
- )
74
- print (
75
- f"OpenVINO not installed globally: { show_supported (not GLOBAL_OPENVINO_INSTALLED )} "
76
- )
77
- if DEVTOOLS_INSTALLED :
78
- print (
79
- f"Numpy version: { NUMPY_VERSION } { show_supported (SUPPORTED_NUMPY_VERSION )} "
80
- )
111
+ print (f"OpenVINO development tools installed: { show_supported (DEVTOOLS_INSTALLED )} " )
112
+ print (f"OpenVINO not installed globally: { show_supported (not GLOBAL_OPENVINO_INSTALLED )} " )
113
+
114
+ print (f"No broken requirements: { show_supported (NO_BROKEN_REQUIREMENTS )} " )
81
115
print ()
82
116
83
117
if not PIP_OPENVINO_INSTALLED :
84
118
print (
85
- f "The OpenVINO PIP package is not installed in this environment. Please\n "
119
+ "The OpenVINO PIP package is not installed in this environment. Please\n "
86
120
"follow the README in the same directory as this check_install script or\n "
87
121
"at https://github.com/openvinotoolkit/openvino_notebooks to install OpenVINO."
88
122
)
89
123
sys .exit (0 )
90
124
91
125
if not OPENVINO_IMPORT and OS != "win32" and not GLOBAL_OPENVINO_INSTALLED :
92
126
print (
93
- f "OpenVINO is installed, but importing fails. This is likely due to a missing\n "
127
+ "OpenVINO is installed, but importing fails. This is likely due to a missing\n "
94
128
"libpython.so library for the Python version you are using.\n "
95
129
)
96
130
if OS == "linux" :
@@ -112,6 +146,11 @@ def show_supported(supported):
112
146
"environment, but if you run into trouble, please follow the instructions \n "
113
147
"in the README to install and activate the `openvino_env` environment.\n "
114
148
)
149
+
150
+ if not CORRECT_KERNEL_PYTHON :
151
+ print ("The Python version in openvino_env does not match the openvino_env "
152
+ "Jupyter kernel. This may not be an issue. If you experience issues, please "
153
+ "follow the instructions in the README to reinstall the kernel." )
115
154
if GLOBAL_OPENVINO_INSTALLED :
116
155
print (
117
156
"It appears that you installed OpenVINO globally (for example with \n "
@@ -143,25 +182,30 @@ def show_supported(supported):
143
182
"Please follow the instructions in the README to install `openvino-dev`\n "
144
183
)
145
184
146
- elif not SUPPORTED_NUMPY_VERSION :
147
- print (
148
- f"You have Numpy version { NUMPY_VERSION } . This may cause issues with model \n "
149
- "optimization or quantization. Please install `numpy<1.19` with \n "
150
- "`pip install numpy<1.19`. There may be errors or warnings in the output \n "
151
- "from pip because of incompatibilities. These should be harmless.\n "
152
- )
185
+ if not NO_BROKEN_REQUIREMENTS :
186
+ print ()
187
+ print ("`pip check` shows broken requirements:" )
188
+ print (PIP_CHECK_OUTPUT )
189
+
190
+ print ()
153
191
if (
154
192
IN_OPENVINO_ENV
155
193
and PIP_OPENVINO_INSTALLED
156
194
and OPENVINO_IMPORT
157
195
and DEVTOOLS_INSTALLED
158
- and SUPPORTED_NUMPY_VERSION
159
196
and SUPPORTED_PYTHON_VERSION
197
+ and KERNEL_INSTALLED
198
+ and CORRECT_KERNEL_PYTHON
160
199
and (not GLOBAL_OPENVINO_INSTALLED )
161
200
):
162
- print ("Everything looks good!" )
201
+ if NO_BROKEN_REQUIREMENTS :
202
+ print ("Everything looks good!" )
203
+ else :
204
+ print ("Summary: The installation looks good, but there are conflicting requirements." )
163
205
else :
164
206
print (
165
207
"The README.md file is located in the openvino_notebooks directory \n "
166
208
"and at https://github.com/openvinotoolkit/openvino_notebooks"
167
209
)
210
+ if not NO_BROKEN_REQUIREMENTS :
211
+ print ("Broken requirements are often harmless, but could cause issues." )
0 commit comments