Skip to content

Commit 2cb7414

Browse files
committed
Merge pull request #9626 from mortada/build_c_ext_msg
improve error message when importing pandas from source directory
2 parents 5db35d0 + 69cab57 commit 2cb7414

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pandas/__init__.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
__docformat__ = 'restructuredtext'
55

66
try:
7-
from . import hashtable, tslib, lib
8-
except Exception: # pragma: no cover
9-
import sys
10-
e = sys.exc_info()[1] # Py25 and Py3 current exception syntax conflict
11-
print(e)
12-
if 'No module named lib' in str(e):
13-
raise ImportError('C extensions not built: if you installed already '
14-
'verify that you are not importing from the source '
15-
'directory')
16-
else:
17-
raise
7+
from pandas import hashtable, tslib, lib
8+
except ImportError as e: # pragma: no cover
9+
module = str(e).lstrip('cannot import name ') # hack but overkill to use re
10+
raise ImportError("C extension: {0} not built. If you want to import "
11+
"pandas from the source directory, you may need to run "
12+
"'python setup.py build_ext --inplace' to build the C "
13+
"extensions first.".format(module))
1814

1915
from datetime import datetime
2016
import numpy as np

0 commit comments

Comments
 (0)