diff --git a/DDCore/python/lcdd.py b/DDCore/python/lcdd.py
index c6da5a236c0e140083d4a05d3b77349608a36783..771bb5f3cf141676025853e3bb00ef9e8fcae512 100644
--- a/DDCore/python/lcdd.py
+++ b/DDCore/python/lcdd.py
@@ -143,12 +143,12 @@ def load_drivers(*args):
     if path.exists(arg):
       if path.isfile(arg):
         logger.info("Loading driver file ... %s" % arg)
-        execfile(arg, drivers)
+        exec(compile(open(arg).read(), arg, 'exec'), drivers)
       elif path.isdir(arg):
         for f in listdir(arg):
           if path.splitext(f)[1] == '.py':
             logger.info("Loading driver file ... %s" % path.join(arg, f))
-            execfile(path.join(arg, f), drivers)
+            exec(compile(open(path.join(arg, f)).read(), path.join(arg, f), 'exec'), drivers)
       else:
         raise "Path '%s' is not a directory or file" % arg
     else:
diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py
index 378d3ba87913de3c558644618dbcb86cdab9b598..d3141dcf089740aff708d186208de87dcdb8c0cb 100644
--- a/DDG4/python/DDSim/DD4hepSimulation.py
+++ b/DDG4/python/DDSim/DD4hepSimulation.py
@@ -116,7 +116,7 @@ class DD4hepSimulation(object):
     if not self.steeringFile:
       return
     sFileTemp = self.steeringFile
-    execfile(self.steeringFile, globs, locs)
+    exec(compile(open(self.steeringFile).read(), self.steeringFile, 'exec'), globs, locs)
     for _name, obj in locs.items():
       if isinstance(obj, DD4hepSimulation):
         self.__dict__ = obj.__dict__