diff --git a/configure b/configure
index ad51997a13292f317820c869305d36f0e2138472..113b119d92e97f25d0cac838e2699058968a50ef 100755
--- a/configure
+++ b/configure
@@ -8760,15 +8760,18 @@ done
   then
     { $as_echo "$as_me:${as_lineno-$LINENO}: Python executable is $PYTHON_BIN" >&5
 $as_echo "$as_me: Python executable is $PYTHON_BIN" >&6;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking support for required python modules (distutils, cython, numpy, subprocess, os)" >&5
-$as_echo_n "checking support for required python modules (distutils, cython, numpy, subprocess, os)... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking support for required python modules (setuptools, cython, numpy, subprocess, os, shutil)" >&5
+$as_echo_n "checking support for required python modules (setuptools, cython, numpy, subprocess, os, shutil)... " >&6; }
 testimport="
-from distutils.core import setup
-from distutils.extension import Extension
-from Cython.Build import cythonize
-import numpy
+from setuptools import setup
+from setuptools import Extension
 import subprocess
 import os
+import os.path
+import sys
+from shutil import copyfile
+import numpy
+from Cython.Build import cythonize
 "
     if echo "$testimport" | "$PYTHON_BIN" 1>/dev/null 2>/dev/null;  then
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
diff --git a/configure.ac b/configure.ac
index aaa860a430eb5612293bd14306e6e5c4ed66b9c2..73a717ce7621307381f933eaa44d1d0c12d877c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -760,14 +760,17 @@ if test $python == true  ; then
   if test -n "$PYTHON_BIN"
   then
     AC_MSG_NOTICE([Python executable is $PYTHON_BIN])
-    AC_MSG_CHECKING([support for required python modules (distutils, cython, numpy, subprocess, os)])
+    AC_MSG_CHECKING([support for required python modules (setuptools, cython, numpy, subprocess, os, shutil)])
 testimport="
-from distutils.core import setup
-from distutils.extension import Extension
-from Cython.Build import cythonize
-import numpy
+from setuptools import setup
+from setuptools import Extension
 import subprocess
 import os
+import os.path
+import sys
+from shutil import copyfile
+import numpy
+from Cython.Build import cythonize
 "
     if echo "$testimport" | "$PYTHON_BIN" 1>/dev/null 2>/dev/null;  then
        AC_MSG_RESULT([yes])
diff --git a/python/setup.py b/python/setup.py
index 6d9fdae9a66819d7ec2c7e6049639eac53aac6f5..eb414cecdfde0b9b2c819b52dff273681f08686a 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -23,7 +23,7 @@
 # This python routine builds an interface between plumed and python using cython
 #
 from setuptools import setup
-from distutils.extension import Extension
+from setuptools import Extension
 import subprocess
 import os
 import os.path