forked from kjordahl/SciPy-Tutorial-2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_env.py
66 lines (52 loc) · 1.4 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
59
60
61
62
63
64
65
66
"""
Test import of required and optional packages for SciPy 2015 tutorial
"""
from __future__ import print_function
import importlib
import sys
def import_version(pkg):
try:
mod = importlib.import_module(pkg)
print(OK, '%s version %s' % (pkg, mod.__version__))
except ImportError:
print(FAIL, '%s not installed' % pkg)
try:
import curses
curses.setupterm()
assert curses.tigetnum("colors") > 2
OK = "\x1b[1;%dm[ OK ]\x1b[0m" % (30 + curses.COLOR_GREEN)
FAIL = "\x1b[1;%dm[FAIL]\x1b[0m" % (30 + curses.COLOR_RED)
except:
OK = '[ OK ]'
FAIL = '[FAIL]'
print('Using python in', sys.prefix)
print(sys.version)
print()
print('Required packages:')
import_version('pyproj')
import_version('fiona')
import_version('shapely')
import_version('rasterio')
import_version('geopandas')
print()
print('Optional packages:')
try:
import osgeo.gdal
print(OK, 'GDAL version', osgeo.gdal.__version__)
except:
print(FAIL, 'GDAL not installed')
try:
from mpl_toolkits.basemap import __version__
print(OK, 'Basemap version', __version__)
except ImportError:
print(FAIL, 'Basemap not installed')
try:
from cartopy import __version__
print(OK, 'Cartopy version', __version__)
except ImportError:
print(FAIL, 'Cartopy not installed')
try:
import geojsonio
print(OK, 'geojsonio installed')
except:
print(FAIL, 'geojsonio not installed')