diff --git a/python/dune/codegen/sumfact/permutation.py b/python/dune/codegen/sumfact/permutation.py
index a7b82eac88ce54b21700dc08514779fc08ba6272..b6a990896db578255a75f1d8a61573d7573c7da4 100644
--- a/python/dune/codegen/sumfact/permutation.py
+++ b/python/dune/codegen/sumfact/permutation.py
@@ -124,6 +124,7 @@ def sumfact_quadrature_permutation_strategy(dim, restriction):
         # all others can be derived by rotating the cube and matching edge
         # directions.
         def _order_on_self(restriction):
+            from dune.codegen.generation import get_global_context_value
             visitor = get_global_context_value("visitor")
             facedir = visitor.get_facedir(restriction)
             facemod = visitor.get_facemod(restriction)