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