diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake
index bd3f9649116d72afee7118e5d3940e5f11a54e4e..73ab6a5b787217c324f1ae83a4320e2a26b4770b 100644
--- a/cmake/modules/DuneCodegenMacros.cmake
+++ b/cmake/modules/DuneCodegenMacros.cmake
@@ -174,11 +174,8 @@ function(add_generated_executable)
 
   if(DUNE_CODEGEN_PROFILING)
     # This is a bit silly, but cProfile only finds entry point scripts
-    # if their full path is provided. So we resort to using which.
-    dune_execute_process(COMMAND which generate_operators
-                         OUTPUT_VARIABLE fullcommand
-                         OUTPUT_STRIP_TRAILING_WHITESPACE
-                         )
+    # if their full path is provided. 
+    set(fullcommand "${DUNE_PYTHON_VIRTUALENV_PATH}/bin/generate_operators")
   endif()
 	
   # Define build rules for all operator header files and gather a list of them