_show_versions.py
1.91 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
Utility methods to print system info for debugging
adapted from :func:`pandas.show_versions`
"""
# License: BSD 3 clause
import platform
import sys
import importlib
from ._openmp_helpers import _openmp_parallelism_enabled
def _get_sys_info():
"""System information
Return
------
sys_info : dict
system and Python version information
"""
python = sys.version.replace('\n', ' ')
blob = [
("python", python),
('executable', sys.executable),
("machine", platform.platform()),
]
return dict(blob)
def _get_deps_info():
"""Overview of the installed version of main dependencies
Returns
-------
deps_info: dict
version information on relevant Python libraries
"""
deps = [
"pip",
"setuptools",
"sklearn",
"numpy",
"scipy",
"Cython",
"pandas",
"matplotlib",
"joblib",
"threadpoolctl"
]
def get_version(module):
return module.__version__
deps_info = {}
for modname in deps:
try:
if modname in sys.modules:
mod = sys.modules[modname]
else:
mod = importlib.import_module(modname)
ver = get_version(mod)
deps_info[modname] = ver
except ImportError:
deps_info[modname] = None
return deps_info
def show_versions():
"""Print useful debugging information"
.. versionadded:: 0.20
"""
sys_info = _get_sys_info()
deps_info = _get_deps_info()
print('\nSystem:')
for k, stat in sys_info.items():
print("{k:>10}: {stat}".format(k=k, stat=stat))
print('\nPython dependencies:')
for k, stat in deps_info.items():
print("{k:>13}: {stat}".format(k=k, stat=stat))
print("\n{k}: {stat}".format(k="Built with OpenMP",
stat=_openmp_parallelism_enabled()))