diff --git a/doc/source/doc/models/building_ctmcs.rst b/doc/source/doc/models/building_ctmcs.rst
index 46c8f8e..97fa418 100644
--- a/doc/source/doc/models/building_ctmcs.rst
+++ b/doc/source/doc/models/building_ctmcs.rst
@@ -3,6 +3,17 @@ Continuous-time Markov chains (CTMCs)
 **************************************
 
 
+.. check if the following doctest should be run (and hide it in Sphinx)
+    >>> # Skip tests if numpy is not available
+    >>> import pytest
+    >>> try:
+    ...     import numpy as np
+    ... except ModuleNotFoundError:
+    ...     np = None
+    >>> if np is None:
+    ...     pytest.skip("skipping the doctest below since it's not going to work.")
+
+
 Background
 =====================
 
diff --git a/doc/source/doc/models/building_mas.rst b/doc/source/doc/models/building_mas.rst
index a840746..823ac9a 100644
--- a/doc/source/doc/models/building_mas.rst
+++ b/doc/source/doc/models/building_mas.rst
@@ -3,6 +3,17 @@ Markov automata (MAs)
 **************************************
 
 
+.. check if the following doctest should be run (and hide it in Sphinx)
+    >>> # Skip tests if numpy is not available
+    >>> import pytest
+    >>> try:
+    ...     import numpy as np
+    ... except ModuleNotFoundError:
+    ...     np = None
+    >>> if np is None:
+    ...     pytest.skip("skipping the doctest below since it's not going to work.")
+
+
 Background
 =====================
 
diff --git a/examples/building_ctmcs/01-building-ctmcs.py b/examples/building_ctmcs/01-building-ctmcs.py
index 8f4acda..0fd0702 100644
--- a/examples/building_ctmcs/01-building-ctmcs.py
+++ b/examples/building_ctmcs/01-building-ctmcs.py
@@ -1,8 +1,18 @@
 import stormpy
-import numpy as np
+
+# Check if numpy is available
+try:
+    import numpy as np
+    numpy_found = True
+except ModuleNotFoundError:
+    numpy_found = False
 
 
 def example_building_ctmcs_01():
+    if not numpy_found:
+        print("Numpy not available")
+        return
+
     # Building the transition matrix using numpy
     transitions = np.array([
         [0, 1.5, 0, 0],
diff --git a/examples/building_mas/01-building-mas.py b/examples/building_mas/01-building-mas.py
index 26bf220..d683741 100644
--- a/examples/building_mas/01-building-mas.py
+++ b/examples/building_mas/01-building-mas.py
@@ -1,8 +1,18 @@
 import stormpy
-import numpy as np
+
+# Check if numpy is available
+try:
+    import numpy as np
+    numpy_found = True
+except ModuleNotFoundError:
+    numpy_found = False
 
 
 def example_building_mas_01():
+    if not numpy_found:
+        print("Numpy not available")
+        return
+
     # Building the transition matrix using numpy
     transitions = np.array([
         [0, 1, 0, 0, 0],
diff --git a/examples/building_mdps/01-building-mdps.py b/examples/building_mdps/01-building-mdps.py
index 1cc510b..60d61d6 100644
--- a/examples/building_mdps/01-building-mdps.py
+++ b/examples/building_mdps/01-building-mdps.py
@@ -1,5 +1,4 @@
 import stormpy
-import numpy as np
 
 
 # Knuth's model of a fair die using only fair coins