diff --git a/setup.cfg b/setup.cfg
index 10fdda8..20ba0d7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -38,7 +38,7 @@ package_dir =
include_package_data = true
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
install_requires =
- importlib-metadata
+ importlib-metadata;python_version<"3.8"
packaging
Sphinx
diff --git a/src/pallets_sphinx_themes/__init__.py b/src/pallets_sphinx_themes/__init__.py
index d16359e..9a3bbd5 100644
--- a/src/pallets_sphinx_themes/__init__.py
+++ b/src/pallets_sphinx_themes/__init__.py
@@ -5,7 +5,11 @@ import sys
import textwrap
from collections import namedtuple
-import importlib_metadata
+if sys.version_info >= (3, 8):
+ from importlib import metadata as importlib_metadata
+else:
+ import importlib_metadata
+
from sphinx.builders._epub_base import EpubBuilder
from sphinx.errors import ExtensionError