-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathcheck_env.py
61 lines (46 loc) · 1.26 KB
/
check_env.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
57
58
"""
Script to check if the required packages for the workshop are installed
Author: Bargava Subramanian
"""
import sys
# requirements
has = dict(
keras='1.0.3',
matplotlib='1.5.1',
numpy='1.11.0',
pandas='0.18',
PIL='3.1.1',
scipy='0.17.0',
sklearn='0.17.0',
tensorflow="0.9",
theano='0.8.2'
)
returns = 0
# check installed packages
for module in has.keys():
try:
_module = module.split('-')[-1]
__module__ = __import__(_module, globals(), locals(), [], 0)
exec('%s = __module__' % _module)
except ImportError:
print("%s:: %s" % (module, sys.exc_info()[1]))
#run.pop(module, None)
returns += 1
# check required versions
from distutils.version import LooseVersion as V
for module,version in has.items():
try:
_module = module.split('-')[-1]
assert V(eval(_module).__version__) >= V(version)
except NameError:
pass # failed import
except AttributeError:
pass # can't version-check non-standard packages...
except AssertionError:
print("%s:: Version >= %s is required" % (module, version))
returns += 1
# final report
if not returns:
print('-'*50)
print('OK. All required items installed.')
sys.exit(returns)