39d50b
diff --git a/config/config_python.py b/config/config_python.py
39d50b
index b747045..2b1ac8d 100644
39d50b
--- a/config/config_python.py
39d50b
+++ b/config/config_python.py
39d50b
@@ -1,12 +1,13 @@
39d50b
+from __future__ import print_function
39d50b
+
39d50b
 import sys
39d50b
 from distutils import sysconfig
39d50b
 
39d50b
 if sys.argv[1] == "archlib":
39d50b
-    print sysconfig.get_python_lib(1,1)
39d50b
+    print(sysconfig.get_python_lib(1,1))
39d50b
 elif sys.argv[1] == "lib":
39d50b
-    print sysconfig.get_python_lib(0,1)
39d50b
+    print(sysconfig.get_python_lib(0,1))
39d50b
 elif sys.argv[1] == "archsitelib":
39d50b
-    print sysconfig.get_python_lib(1,0)
39d50b
+    print(sysconfig.get_python_lib(1,0))
39d50b
 elif sys.argv[1] == "sitelib":
39d50b
-    print sysconfig.get_python_lib(0,0)
39d50b
-
39d50b
+    print(sysconfig.get_python_lib(0,0))
39d50b
diff --git a/configure.ac b/configure.ac
39d50b
index 51166c3..4d8c9a0 100644
39d50b
--- a/configure.ac
39d50b
+++ b/configure.ac
39d50b
@@ -1142,7 +1142,7 @@ else
39d50b
     if test `$SWIG -help 2>&1 | $EGREP -c '\-python *- Generate'` = 0; then
39d50b
       use_python="No (swig does not support -python option)"
39d50b
     else
39d50b
-      AC_CHECK_PROG(PYTHON,python,python)
39d50b
+      AC_CHECK_PROGS(PYTHON,[python3 python])
39d50b
       if test "x$PYTHON" = "x"; then
39d50b
         use_python="No (python not available)"
39d50b
       else
39d50b
@@ -1167,8 +1167,11 @@ else
39d50b
       if test "x$PYTHON" = "x"; then
39d50b
 	use_python="No (python is too old)"
39d50b
       else
39d50b
-        PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
39d50b
+        PYTHON_PREFIX=`$PYTHON -c "import sys; print(sys.prefix)"`
39d50b
         PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION_SHORT
39d50b
+        if test $PYTHON_VERSION_MAJOR -gt 2; then
39d50b
+          PYTHON_INCLUDES="${PYTHON_INCLUDES}m"
39d50b
+        fi
39d50b
 #        PYTHON_LIBS="-lpython$PYTHON_VERSION_SHORT"
39d50b
 	PYTHON_LIBS="-undefined dynamic_lookup"
39d50b
         PYTHON_INSTALL_DIR="`$PYTHON $srcdir/config/config_python.py archsitelib`"
39d50b
@@ -1548,7 +1551,7 @@ else
39d50b
       if test "x$PYTHON34" = "x"; then
39d50b
 	    use_python34="No (python34 is too old)"
39d50b
       else
39d50b
-        PYTHON34_PREFIX=`$PYTHON3 -c "import sys; print sys.prefix"`
39d50b
+        PYTHON34_PREFIX=`$PYTHON3 -c "import sys; print(sys.prefix)"`
39d50b
 #        PYTHON34_INCLUDES=-I$PYTHON34_PREFIX/include/python$PYTHON34_VERSION_SHORT
39d50b
 # FIXME - whats the stupid "m" for?
39d50b
         PYTHON34_INCLUDES=-I/usr/include/python3.4m