diff --git a/sphinx_gallery/backreferences.py b/sphinx_gallery/backreferences.py
index 4fe579c..28cf10a 100644
--- a/sphinx_gallery/backreferences.py
+++ b/sphinx_gallery/backreferences.py
@@ -103,7 +103,13 @@ def identify_names(code):
     for name, full_name in finder.get_mapping():
         # name is as written in file (e.g. np.asarray)
         # full_name includes resolved import path (e.g. numpy.asarray)
-        module, attribute = full_name.rsplit('.', 1)
+        splitted = full_name.rsplit('.', 1)
+        if len(splitted) == 1:
+            # module without attribute. This is not useful for
+            # backreferences
+            continue
+
+        module, attribute = splitted
         # get shortened module name
         module_short = get_short_module_name(module, attribute)
         cobj = {'name': attribute, 'module': module,

diff --git a/sphinx_gallery/tests/test_backreferences.py b/sphinx_gallery/tests/test_backreferences.py
index d820378..1e9e6c9 100644
--- a/sphinx_gallery/tests/test_backreferences.py
+++ b/sphinx_gallery/tests/test_backreferences.py
@@ -60,3 +60,33 @@ def test_backref_thumbnail_div():
 """
 
     assert_equal(html_div, reference)
+
+
+def test_identify_names():
+    code_str = """
+import os
+os
+
+os.path.join
+
+import sphinx_gallery.back_references as br
+br.identify_names
+
+from sphinx_gallery.back_references import identify_names
+identify_names
+"""
+    res = sg.identify_names(code_str)
+    expected = {
+        'os.path.join':
+            {'name': 'join', 'module': 'os.path', 'module_short': 'os.path'},
+        'br.identify_names':
+            {'name': 'identify_names',
+             'module': 'sphinx_gallery.back_references',
+             'module_short': 'sphinx_gallery.back_references'},
+        'identify_names':
+            {'name': 'identify_names',
+             'module': 'sphinx_gallery.back_references',
+             'module_short': 'sphinx_gallery.back_references'}
+        }
+
+    assert_equal(expected, res)

backreferences processing breaks if module accessed without attribute
The scikit-learn docs fail to build at https://circleci.com/gh/scikit-learn/scikit-learn/7314?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link due to https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/backreferences.py#L106 where it is assumed that a module being referenced is always referenced with an attribute. It should be possible to reference a module without its attribute and hence for no `.` to be present.
sphinx_gallery/tests/test_backreferences.py::test_identify_names
sphinx_gallery/tests/test_backreferences.py::test_thumbnail_div sphinx_gallery/tests/test_backreferences.py::test_backref_thumbnail_div