diff --git a/Makefile b/Makefile
index 140822a63eb08e10d271bfaa5a3fd2aaaaaf3588..e762596796daaafc8532d07757a47fb6c9e06ea9 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ default: groupConnectivity.so clean_obj
 
 groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h generateCompileTimeOptions.sh rings.h fast-array.h twoCuts.h parmap.py groupConnectivityNaive.py
 	./generateCompileTimeOptions.sh > options.h
-	python setup.py build_ext
+	python2 setup.py build_ext
 	cp build/lib*/groupConnectivity.so .
 
 clean_obj:
diff --git a/groupConnectivityNaive.py b/groupConnectivityNaive.py
index 8f15d7153f3cf3e3ef8850ce5de463b8684ecba2..88c5bd204f8ad9f50cc41899a776bd11795b832f 100644
--- a/groupConnectivityNaive.py
+++ b/groupConnectivityNaive.py
@@ -155,6 +155,7 @@ if __name__ == "__main__":
   (f, t) = doctest.testmod()
   print "%s: %i tests of %i failed." % (__file__, f, t)
   if f > 0:
+    from sys import exit
     exit(1)
 
 
diff --git a/parmap.py b/parmap.py
index 86374608ec047ae68ccac26cf47a499517cf462a..f3dc40d29d40a173504e68faf4d6fbea38aad7e8 100644
--- a/parmap.py
+++ b/parmap.py
@@ -146,5 +146,6 @@ if __name__ == "__main__":
   (f, t) = doctest.testmod()
   print "%s: %i tests of %i failed." % (__file__, f, t)
   if f > 0:
+    from sys import exit
     exit(1)