Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'ExtensionError' #2

Closed
dputhier opened this issue Jun 18, 2019 · 4 comments
Closed

cannot import name 'ExtensionError' #2

dputhier opened this issue Jun 18, 2019 · 4 comments

Comments

@dputhier
Copy link

Hi,
When using sphinxcontrib.googleanalytics with Python 3.6.7, I'm getting the following error:

Extension error:
Could not import extension sphinxcontrib.googleanalytics (exception: cannot import name 'ExtensionError')

I managed to get it work using this workaround:

 # https://jiangsheng.net/2019/01/05/fix-sphinxcontrib-googleanalytics-on-sphinx-1-8/
 # Fix is to change googleanalytics.py Line 4 
 # from
 # from sphinx.application import ExtensionError
 # to
 # from sphinx.errors import ExtensionError

However, this would be better to provide a fix as the module is not usable in this version in a production environment.
Best

@SuperKogito
Copy link

Since this is still not fixed, despite the existing pull request. I am leaving this here for Linux based system users & Sphinx (2.1.0) with python3. As @dputhier already mentioned, the fix is to replace from sphinx.application import ExtensionError with from sphinx.errors import ExtensionError in /usr/local/lib/python3.6/dist-packages/sphinxcontrib_googleanalytics.../sphinxcontrib/googleanalytics.py

@dputhier
Copy link
Author

dputhier commented Sep 8, 2020

Just for information, the file of interest can also be located in
.../lib/python3.7/site-packages/sphinxcontrib/googleanalytics.py

@pyhys
Copy link

pyhys commented Oct 15, 2020

As a workaround you can add this to the top of your conf.py file:

# Workaround for issue https://github.com/sphinx-contrib/googleanalytics/issues/2
# Note that a warning still will be issued "unsupported object from its setup() function"
# Remove this workaround when the issue has been resolved upstream
import sphinx.application
import sphinx.errors
sphinx.application.ExtensionError = sphinx.errors.ExtensionError

@jelmer
Copy link
Collaborator

jelmer commented Nov 28, 2022

I believe this is obsolete now #1 has been merged.

@jelmer jelmer closed this as completed Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants