1diff --git a/astropy_helpers/tests/test_git_helpers.py b/astropy_helpers/tests/test_git_helpers.py
2index 6b826fc..3fb3a29 100644
3--- a/astropy_helpers/tests/test_git_helpers.py
4+++ b/astropy_helpers/tests/test_git_helpers.py
5@@ -1,5 +1,5 @@
6 import glob
7-import imp
8+import importlib as imp
9 import os
10 import pkgutil
11 import re
12diff --git a/astropy_helpers/utils.py b/astropy_helpers/utils.py
13index 115c915..0cfc9e3 100644
14--- a/astropy_helpers/utils.py
15+++ b/astropy_helpers/utils.py
16@@ -1,12 +1,12 @@
17 # Licensed under a 3-clause BSD style license - see LICENSE.rst
18
19 import contextlib
20-import imp
21 import os
22 import sys
23 import glob
24
25 from importlib import machinery as import_machinery
26+from importlib import util as importlib_util
27
28
29 # Note: The following Warning subclasses are simply copies of the Warnings in
30@@ -54,9 +54,9 @@ def get_numpy_include_path():
31 import builtins
32 if hasattr(builtins, '__NUMPY_SETUP__'):
33 del builtins.__NUMPY_SETUP__
34- import imp
35+ import importlib
36 import numpy
37- imp.reload(numpy)
38+ importlib.reload(numpy)
39
40 try:
41 numpy_include = numpy.get_include()
42@@ -208,8 +208,6 @@ def import_file(filename, name=None):
43 # generates an underscore-separated name which is more likely to
44 # be unique, and it doesn't really matter because the name isn't
45 # used directly here anyway.
46- mode = 'r'
47-
48 if name is None:
49 basename = os.path.splitext(filename)[0]
50 name = '_'.join(os.path.relpath(basename).split(os.sep)[1:])
51@@ -221,8 +219,10 @@ def import_file(filename, name=None):
52 loader = import_machinery.SourceFileLoader(name, filename)
53 mod = loader.load_module()
54 else:
55- with open(filename, mode) as fd:
56- mod = imp.load_module(name, fd, filename, ('.py', mode, 1))
57+ importlib_util
58+ spec = importlib_util.spec_from_file_location(name, filename)
59+ mod = importlib_util.module_from_spec(spec)
60+ spec.loader.exec_module(mod)
61
62 return mod
63