diff --git a/var/spack/repos/builtin.mock/packages/multimethod/package.py b/var/spack/repos/builtin.mock/packages/multimethod/package.py
index 9e18d65cbb908abeae7bebccbd0a0c7d1b74d9bf..c0e347bc9326bab9df938524aa2d3f4a2805e898 100644
--- a/var/spack/repos/builtin.mock/packages/multimethod/package.py
+++ b/var/spack/repos/builtin.mock/packages/multimethod/package.py
@@ -22,6 +22,8 @@
 # License along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
+from six import string_types
+
 from spack import *
 import spack.architecture
 
@@ -102,14 +104,14 @@ def has_a_default(self):
     # Make sure we can switch methods on different target
     #
     platform = spack.architecture.platform()
-    targets = platform.targets.values()
+    targets = list(platform.targets.values())
     if len(targets) > 1:
         targets = targets[:-1]
 
     for target in targets:
         @when('target=' + target.name)
         def different_by_target(self):
-            if isinstance(self.spec.architecture.target, basestring):
+            if isinstance(self.spec.architecture.target, string_types):
                 return self.spec.architecture.target
             else:
                 return self.spec.architecture.target.name
diff --git a/var/spack/repos/builtin/packages/hdf5-blosc/package.py b/var/spack/repos/builtin/packages/hdf5-blosc/package.py
index 4afce02f70d76af3de3e792601cc40b67dab2d14..eb63d08dfdc8c17c354311ab934e13403793d325 100644
--- a/var/spack/repos/builtin/packages/hdf5-blosc/package.py
+++ b/var/spack/repos/builtin/packages/hdf5-blosc/package.py
@@ -22,7 +22,7 @@
 # License along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
-
+from __future__ import print_function
 import os
 import shutil
 import sys
@@ -115,7 +115,7 @@ def install(self, spec, prefix):
 
     def check_install(self, spec):
         "Build and run a small program to test the installed HDF5 Blosc plugin"
-        print "Checking HDF5-Blosc plugin..."
+        print("Checking HDF5-Blosc plugin...")
         checkdir = "spack-check"
         with working_dir(checkdir, create=True):
             source = r"""\
@@ -188,16 +188,16 @@ def check_install(self, spec):
                 output = ""
             success = output == expected
             if not success:
-                print "Produced output does not match expected output."
-                print "Expected output:"
-                print "-" * 80
-                print expected
-                print "-" * 80
-                print "Produced output:"
-                print "-" * 80
-                print output
-                print "-" * 80
-                print "Environment:"
+                print("Produced output does not match expected output.")
+                print("Expected output:")
+                print("-" * 80)
+                print(expected)
+                print("-" * 80)
+                print("Produced output:")
+                print("-" * 80)
+                print(output)
+                print("-" * 80)
+                print("Environment:")
                 env = which("env")
                 env()
                 raise RuntimeError("HDF5 Blosc plugin check failed")
diff --git a/var/spack/repos/builtin/packages/miniconda2/package.py b/var/spack/repos/builtin/packages/miniconda2/package.py
index 10b85cef326084d41c838173da4e856d88f62c55..d23ab080b05aa28e6bb1946597fdda5e66dfadf8 100644
--- a/var/spack/repos/builtin/packages/miniconda2/package.py
+++ b/var/spack/repos/builtin/packages/miniconda2/package.py
@@ -23,7 +23,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
 from spack import *
-from urlparse import urlparse
+from six.moves.urllib.parse import urlparse
 from os.path import split
 
 
diff --git a/var/spack/repos/builtin/packages/miniconda3/package.py b/var/spack/repos/builtin/packages/miniconda3/package.py
index cd0677b5bca685494dcf67e4b55f980caee0b9fc..8184c10d88a7f81731a9874f37cc844a6bd4304b 100644
--- a/var/spack/repos/builtin/packages/miniconda3/package.py
+++ b/var/spack/repos/builtin/packages/miniconda3/package.py
@@ -23,7 +23,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
 from spack import *
-from urlparse import urlparse
+from six.moves.urllib.parse import urlparse
 from os.path import split
 
 
diff --git a/var/spack/repos/builtin/packages/ncl/package.py b/var/spack/repos/builtin/packages/ncl/package.py
index 9f834eee3b7573723cc97803d38f877d470c9423..b7394cff320da39786ce4357f83d7ba06f3966ec 100644
--- a/var/spack/repos/builtin/packages/ncl/package.py
+++ b/var/spack/repos/builtin/packages/ncl/package.py
@@ -229,6 +229,6 @@ def delete_files(*filenames):
             if os.path.exists(filename):
                 try:
                     os.remove(filename)
-                except OSError, e:
+                except OSError as e:
                     raise InstallError('Failed to delete file %s: %s' % (
                         e.filename, e.strerror))
diff --git a/var/spack/repos/builtin/packages/nwchem/package.py b/var/spack/repos/builtin/packages/nwchem/package.py
index f39d8ad0c793a1169c18462f8a589f82733ca5ca..3a8be3f56ea604563be0871a97b5c60b66d64e59 100644
--- a/var/spack/repos/builtin/packages/nwchem/package.py
+++ b/var/spack/repos/builtin/packages/nwchem/package.py
@@ -68,7 +68,7 @@ class Nwchem(Package):
         ]
     }
     # Iterate over patches
-    for condition, urls in urls_for_patches.iteritems():
+    for condition, urls in urls_for_patches.items():
         for url, md5 in urls:
             patch(url, when=condition, level=0, md5=md5)