diff --git a/cms/envs/common.py b/cms/envs/common.py
index 206182b89e94a46fecb2b10538ada66bc86ca144..99d7a3102c3e1cf100f14f03bad2c2e7bef402ac 100644
--- a/cms/envs/common.py
+++ b/cms/envs/common.py
@@ -40,7 +40,7 @@ When refering to XBlocks, we use the entry-point name. For example,
 
 # pylint: disable=unused-import, useless-suppression, wrong-import-order, wrong-import-position
 
-import imp
+import importlib.util
 import os
 import sys
 from datetime import timedelta
@@ -1623,10 +1623,8 @@ OPTIONAL_APPS = (
 for app_name, insert_before in OPTIONAL_APPS:
     # First attempt to only find the module rather than actually importing it,
     # to avoid circular references - only try to import if it can't be found
-    # by find_module, which doesn't work with import hooks
-    try:
-        imp.find_module(app_name)
-    except ImportError:
+    # by find_spec, which doesn't work with import hooks
+    if importlib.util.find_spec(app_name) is None:
         try:
             __import__(app_name)
         except ImportError:
diff --git a/lms/envs/common.py b/lms/envs/common.py
index 4cfa792cdd68edc780e7e80d6c1e30090e69e85e..220a988a2238c84d77fab3bcf410579ad2074a32 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -29,7 +29,7 @@ Longer TODO:
 # pylint: disable=invalid-name, wrong-import-position
 
 
-import imp
+import importlib.util
 import sys
 import os
 
@@ -3181,10 +3181,8 @@ OPTIONAL_APPS = [
 for app_name, insert_before in OPTIONAL_APPS:
     # First attempt to only find the module rather than actually importing it,
     # to avoid circular references - only try to import if it can't be found
-    # by find_module, which doesn't work with import hooks
-    try:
-        imp.find_module(app_name)
-    except ImportError:
+    # by find_spec, which doesn't work with import hooks
+    if importlib.util.find_spec(app_name) is None:
         try:
             __import__(app_name)
         except ImportError: