diff --git a/pycgtool/frame.py b/pycgtool/frame.py
index 5edd16e4dc45ce54b070d83befca2d9ce79ea92a..c50fb96119840063173bf98f4063ece1af4506de 100644
--- a/pycgtool/frame.py
+++ b/pycgtool/frame.py
@@ -200,7 +200,7 @@ class Frame:
             try:
                 import mdtraj
             except ImportError as e:
-                if "scipy" in e.msg:
+                if "scipy" in repr(e):
                     e.msg = "XTC output with MDTraj also requires Scipy"
                 else:
                     e.msg = "XTC output requires the module MDTraj (and probably Scipy)"
diff --git a/pycgtool/framereader.py b/pycgtool/framereader.py
index 9a4fcb3d79ffd25d0a30c29cf63a96da5112ed73..c843f7778d3683ca6d1e11e1eda3c597e069fd47 100644
--- a/pycgtool/framereader.py
+++ b/pycgtool/framereader.py
@@ -181,7 +181,7 @@ class FrameReaderMDTraj(FrameReader):
         try:
             import mdtraj
         except ImportError as e:
-            if "scipy" in e.msg:
+            if "scipy" in repr(e):
                 e.msg = "The MDTraj FrameReader also requires Scipy"
             else:
                 e.msg = "The MDTraj FrameReader requires the module MDTraj (and probably Scipy)"