-
Notifications
You must be signed in to change notification settings - Fork 807
/
check-installation.py
66 lines (59 loc) · 1.69 KB
/
check-installation.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
59
60
61
62
63
64
65
66
# -----------------------------------------------------------------------------
# Copyright (c) 2016, Nicolas P. Rougier. All Rights Reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
from distutils.version import LooseVersion
# Check for python
import sys
if sys.version_info <= (3,0):
print("This tutorial requires Python 3\n")
sys.exit()
# Check for numpy
try:
import numpy as np
except:
print("This tutorial requires numpy\n")
sys.exit()
print("Check for numpy: ", end="")
if LooseVersion(np.__version__) < LooseVersion("1.0"):
print("numpy too old (< 1.0)\n")
sys.exit()
else:
print("ok")
# Check for matplotlib
try:
import matplotlib as mpl
except:
print("This tutorial requires matplotib\n")
sys.exit()
print("Check for matplotlib: ", end="")
if LooseVersion(mpl.__version__) < LooseVersion("1.5"):
print("matplotlib too old (< 1.5)\n")
sys.exit()
else:
print("ok")
# Check for basemap or cartopy
try:
import mpl_toolkits.basemap as basemap
check_for_cartopy = False
except:
check_for_cartopy = True
else:
print("Check for basemap: ", end="")
if LooseVersion(basemap.__version__) < LooseVersion("1.0"):
print("basemap is too old (< 1.0) \n")
sys.exit()
else:
print("ok")
if check_for_cartopy:
try:
import cartopy
except:
print("This tutorial requires either basemap or cartopy\n")
sys.exit()
print("Check for cartopy: ", end="")
if LooseVersion(cartopy.__version__) < LooseVersion("0.15"):
print("cartopy is too old (< 0.15) \n")
sys.exit()
else:
print("ok")