Skip to content

Commit 1d6d7d4

Browse files
Marco Farrugiajreback
Marco Farrugia
authored andcommitted
MAINT: Nicely inform users if they're missing hard dependencies.
closes #12176 closes #12468
1 parent fe584e7 commit 1d6d7d4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pandas/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44

55
__docformat__ = 'restructuredtext'
66

7+
# Let users know if they're missing any of our hard dependencies
8+
hard_dependencies = ("numpy", "pytz", "dateutil")
9+
missing_dependencies = []
10+
11+
for dependency in hard_dependencies:
12+
try:
13+
__import__(dependency)
14+
except ImportError as e:
15+
missing_dependencies.append(dependency)
16+
17+
if missing_dependencies:
18+
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
19+
20+
721
# numpy compat
8-
import numpy as np
922
from pandas.compat.numpy_compat import *
1023

1124
try:
@@ -49,4 +62,3 @@
4962
v = get_versions()
5063
__version__ = v.get('closest-tag',v['version'])
5164
del get_versions, v
52-

pandas/compat/numpy_compat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
6666

6767
return np.array(arr, *args, **kwargs)
6868

69-
__all__ = ['_np_version',
69+
__all__ = ['np',
70+
'_np_version',
7071
'_np_version_under1p8',
7172
'_np_version_under1p9',
7273
'_np_version_under1p10',

0 commit comments

Comments
 (0)