This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcheck_env.py
More file actions
70 lines (58 loc) · 1.97 KB
/
check_env.py
File metadata and controls
70 lines (58 loc) · 1.97 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
"""
Check for required and optional dependencies for the Astropy tutorial for SciPy2014:
- astropy: 0.3.2 or later required, 0.4 optimal
- numpy: required (version depends on astropy version)
- scipy: required
- matplotlib: required
- bs4 (BeautifulSoup): optional
Usage::
% python check_env.py
"""
warnings = False
errors = False
try:
import astropy
except ImportError as err:
print('Error: Failed import: {0}'.format(err))
errors = True
else:
# Astropy version 0.3.2 or later, and 0.4.0 for coordinates
astropy_version = astropy.__version__
if astropy_version < '0.3.2':
print('Error: astropy version 0.3.2 or later is required, you have {0}'
.format(astropy.__version__))
errors = True
elif astropy_version < '0.4.0':
print('Warning: astropy version 0.4.0 is later is needed for the '
'coordinates part of the tutorial, you have {0}. Consider installing 0.4 '
'if you want to do the coordinates exercises.'.format(astropy.__version__))
warnings = True
try:
import numpy
except ImportError as err:
print('Error: Failed import: {0}'.format(err))
errors = True
try:
import scipy
except ImportError as err:
print('Error: Failed import: {0}'.format(err))
errors = True
try:
import matplotlib
except ImportError as err:
print('Error: Failed import: {0}'.format(err))
errors = True
# BeautifulSoup4 for one bit of the ASCII tables section.
try:
import bs4
except ImportError:
print('Warning: BeautifulSoup4 is not installed, so you will not be able to '
'run the example for reading HTML tables.')
warnings = True
print('\nAstropy tutorial environment check summary:')
if errors:
print(' There are errors that you must resolve before running the tutorial.')
if warnings:
print(' There are warnings and some parts of the tutorial will not work.')
if not errors and not warnings:
print(' Your Python environment is good to go!')