Fix sphinxcontrib-googleanalytics on Sphinx 1.8

The Google Analytics extension from

python -m pip install  sphinxcontrib-googleanalytics

does not work on Sphinx 1.8. When I run it, I get the following error

Could not import extension sphinxcontrib.googleanalytics (exception: cannot import name ‘ExtensionError’ from ‘sphinx.application’ (c:\python37\lib\site-packages\sphinx\application.py))

Fix is to change C:\Python37\Lib\site-packages\sphinxcontrib\googleanalytics.py Line 4

from

from sphinx.application import ExtensionError

to

from sphinx.errors import ExtensionError

After that I get another warning

WARNING: extension ‘sphinxcontrib.googleanalytics’ returned an unsupported object from its setup() function; it should return None or a metadata dictionary

Fix is to change the last line from

return app

to

return {‘version’: ‘0.1’}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.