diff --git a/dev-docs/source/conf.py b/dev-docs/source/conf.py
index 8e39dfd9387c7dd080ceb408f995143908822d37..13d67fcecaa3062d0e883867f2e220d7c37e89f8 100644
--- a/dev-docs/source/conf.py
+++ b/dev-docs/source/conf.py
@@ -7,11 +7,12 @@ import os
 
 from sphinx import __version__ as sphinx_version
 import sphinx_bootstrap_theme
+from distutils.version import LooseVersion
 
 
 # -- General configuration ------------------------------------------------
 
-if sphinx_version > "1.6":
+if LooseVersion(sphinx_version) > LooseVersion("1.6"):
     def setup(app):
         """Called automatically by Sphinx when starting the build process
         """
@@ -28,7 +29,7 @@ extensions = [
     'sphinx.ext.intersphinx'
 ]
 
-if sphinx_version > "1.8":
+if LooseVersion(sphinx_version) > LooseVersion("1.8"):
     extensions.append('sphinx.ext.imgmath')
 else:
     extensions.append('sphinx.ext.pngmath')
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 41971491c7479745f2178b14b3cc17ae48785785..6b71e808e5ce49c447822ab390ef44fd9b9f9f31 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -9,6 +9,7 @@ from sphinx import __version__ as sphinx_version
 import sphinx_bootstrap_theme # checked at cmake time
 import mantid
 from mantid.kernel import ConfigService
+from distutils.version import LooseVersion
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -17,7 +18,7 @@ sys.path.insert(0, os.path.abspath(os.path.join('..', 'sphinxext')))
 
 # -- General configuration ------------------------------------------------
 
-if sphinx_version > "1.6":
+if LooseVersion(sphinx_version) > LooseVersion("1.6"):
     def setup(app):
         """Called automatically by Sphinx when starting the build process
         """
@@ -38,7 +39,7 @@ extensions = [
     'mantiddoc.doctest',
     'matplotlib.sphinxext.plot_directive'
 ]
-if sphinx_version > "1.8":
+if LooseVersion(sphinx_version) > LooseVersion("1.8"):
     extensions.append('sphinx.ext.imgmath')
 else:
     extensions.append('sphinx.ext.pngmath')