diff --git a/gwinc/test/__main__.py b/gwinc/test/__main__.py
index 3c638f76f9438d4f837cdd583c9d9184d2d8173e..cfe52ed962c45bf6d7737f79b8ecb02bb0a4ff0a 100644
--- a/gwinc/test/__main__.py
+++ b/gwinc/test/__main__.py
@@ -90,7 +90,7 @@ def gen_cache(git_hash, path):
     """
     logging.info("creating new cache for hash {}...".format(git_hash))
     subprocess.run(
-        [test_path('gen_cache.sh'), git_hash, path],
+        [test_path('gen_cache.sh'), git_hash, path, sys.executable],
         check=True,
     )
 
diff --git a/gwinc/test/gen_cache.sh b/gwinc/test/gen_cache.sh
index 99bfd9bbad47769fe284baf462be648e4fd02712..42bf206ebca6bc34a74f3bccbcae38bae0d0bbff 100755
--- a/gwinc/test/gen_cache.sh
+++ b/gwinc/test/gen_cache.sh
@@ -8,6 +8,8 @@ fi
 
 git_hash="$1"
 cache_dir="$2"
+python="$3"
+[ -z "$python" ] && python=python3
 
 mkdir -p $cache_dir
 cache_dir=$(cd $cache_dir && pwd)
@@ -19,8 +21,8 @@ git archive $git_hash | tar -x -C $gwinc_dir
 cd $gwinc_dir
 
 export LOG_LEVEL=INFO
-for ifo in $(python3 -c "import gwinc; print(' '.join(gwinc.IFOS))") ; do
-    python3 -m gwinc --save $cache_dir/${ifo}.h5 $ifo
+for ifo in $($python -c "import gwinc; print(' '.join(gwinc.IFOS))") ; do
+    $python -m gwinc --save $cache_dir/${ifo}.h5 $ifo
 done
 
 echo $git_hash > $cache_dir/git_hash