Skip to content

Commit f2dd238

Browse files
committed
sparse: add try/catch for detecting if Scipy is installed
1 parent 17ac36c commit f2dd238

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/scipy-type.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ const PyTypeObject* ScipyType::getScipyCSCMatrixType() {
2828
}
2929

3030
ScipyType::ScipyType() {
31-
sparse_module = bp::import("scipy.sparse");
31+
try {
32+
sparse_module = bp::import("scipy.sparse");
33+
} catch (...) {
34+
throw std::runtime_error(
35+
"SciPy is not installed. "
36+
"You can install it using the command \'pip install scipy\'.");
37+
}
3238

3339
#if PY_MAJOR_VERSION >= 3
3440
// TODO I don't know why this Py_INCREF is necessary.

0 commit comments

Comments
 (0)