sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.43k stars 2.1k forks source link

Extension error: Could not import extension sphinx.builders.linkcheck (exception: No module named exceptions) #5232

Closed ajinkya-deogade closed 6 years ago

ajinkya-deogade commented 6 years ago

Subject: I tried to build documentation using Sphinx on my laptop (python v2.7.15, Sphinx v1.7.6) as well as on ReadTheDocs.

Problem

At both the places I am getting following error:

Error on Laptop

sphinx-build -b html ./docs/ ./docs/build/ Running Sphinx v1.7.6 loading translations [en]... done

Extension error: Could not import extension sphinx.builders.linkcheck (exception: No module named exceptions)

Error on ReadTheDocs

Running Sphinx v1.7.6 loading translations [en]... done

Traceback (most recent call last): File "/home/docs/checkouts/readthedocs.org/user_builds/generalized-enhancer-predictor/envs/latest/local/lib/python2.7/site-packages/sphinx/cmdline.py", line 303, in main args.warningiserror, args.tags, args.verbosity, args.jobs) File "/home/docs/checkouts/readthedocs.org/user_builds/generalized-enhancer-predictor/envs/latest/local/lib/python2.7/site-packages/sphinx/application.py", line 187, in init self.setup_extension(extension) File "/home/docs/checkouts/readthedocs.org/user_builds/generalized-enhancer-predictor/envs/latest/local/lib/python2.7/site-packages/sphinx/application.py", line 411, in setup_extension self.registry.load_extension(self, extname) File "/home/docs/checkouts/readthedocs.org/user_builds/generalized-enhancer-predictor/envs/latest/local/lib/python2.7/site-packages/sphinx/registry.py", line 318, in load_extension raise ExtensionError(__('Could not import extension %s') % extname, err) ExtensionError: Could not import extension sphinx.builders.linkcheck (exception: No module named exceptions)

Extension error: Could not import extension sphinx.builders.linkcheck (exception: No module named exceptions)

Procedure to reproduce the problem

pip freeze on my laptop gives below result: alabaster==0.7.11 appnope==0.1.0 asn1crypto==0.24.0 autopep8==1.3.5 Babel==2.6.0 backports-abc==0.5 backports.functools-lru-cache==1.5 backports.shutil-get-terminal-size==1.0.0 backports.ssl-match-hostname==3.5.0.1 biopython==1.71 bleach==2.1.3 bokeh==0.13.0 bz2file==0.98 CacheControl==0.12.5 certifi==2018.4.16 cffi==1.11.5 chardet==3.0.4 clustergrammer==1.13.5 clustergrammer-widget==1.13.3 configparser==3.5.0 contextlib2==0.5.5 cryptography==2.2.2 cycler==0.10.0 Cython==0.28.3 decorator==4.3.0 docutils==0.14 entrypoints==0.2.3 enum34==1.1.6 fastcluster==1.1.25 functools32==3.2.3.post2 future==0.14.3 futures==3.2.0 GEOparse==1.0.3 html5lib==1.0.1 idna==2.7 imagesize==1.0.0 ipaddress==1.0.22 ipykernel==4.8.2 ipyparallel==6.2.2 ipython==5.7.0 ipython-genutils==0.2.0 ipywidgets==7.2.1 Jinja2==2.10 joblib==0.12.0 jsonschema==2.6.0 jupyter-client==5.2.3 jupyter-core==4.4.0 jupyterlab==0.32.1 jupyterlab-launcher==0.10.5 kiwisolver==1.0.1 lockfile==0.12.2 lxml==4.2.2 MarkupSafe==0.23 matplotlib==2.2.2 matplotlib-venn==0.11.5 mistune==0.8.3 msgpack==0.5.6 msgpack-python==0.5.6 multiprocessing==2.6.2.1 natsort==3.5.0 nbconvert==5.3.1 nbformat==4.4.0 nose==1.3.7 notebook==5.5.0 numpy==1.14.5 opencv-python==3.3.1.11 packaging==17.1 pandas==0.23.1 pandas-datareader==0.6.0 pandas-profiling==1.4.1 pandocfilters==1.4.2 pathlib2==2.3.2 pexpect==4.6.0 pickleshare==0.7.4 prompt-toolkit==1.0.15 ptyprocess==0.6.0 pybiomart==0.2.0 pycodestyle==2.4.0 pycparser==2.18 pyflann==1.6.14 Pygments==2.2.0 pyOpenSSL==18.0.0 pyparsing==2.2.0 pypolyagamma==1.1.4 PySocks==1.6.8 python-dateutil==2.7.3 pytz==2018.5 PyYAML==3.13 pyzmq==17.0.0 requests==2.19.1 requests-cache==0.4.13 requests-file==1.4.3 requests-ftp==0.3.1 rpy2==2.8.6 rpy2-bioconductor-extensions==0.2.5.dev0 scandir==1.7 scikit-bio==0.2.3 scikit-learn==0.19.1 scipy==1.1.0 seaborn==0.8.1 Send2Trash==1.5.0 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.11.0 sk-video==1.1.10 snowballstemmer==1.2.1 Sphinx==1.7.6 sphinxcontrib-websupport==1.1.0 subprocess32==3.5.2 tabulate==0.8.2 terminado==0.8.1 testpath==0.3.1 tornado==5.0.2 tqdm==4.23.4 traitlets==4.3.2 typing==3.6.4 urllib3==1.23 wcwidth==0.1.7 webencodings==0.5.1 wget==3.2 wgetter==0.7 widgetsnbextension==3.2.1 wrapt==1.10.11 xlrd==1.1.0

Error logs / results

Reproducible project / your project

Environment info

tk0miya commented 6 years ago

I guess the error was raised on this line: https://github.com/sphinx-doc/sphinx/blob/5fd62810b936b376e02e21b987851ffe602a03b7/sphinx/builders/linkcheck.py#L19

And it seems your project overrides requests package by mock object: https://github.com/ajinkya-deogade/GEP/blob/f820dba5aa6d2e54d4c7e366fef60bf5de39c619/docs/conf.py#L44-L52

linkcheck builder is strongly coupled with requests module. I think this behavior is not a bug. Could you check your settings please?

ajinkya-deogade commented 6 years ago

Thanks for pointing out the error. It was the mock object in my conf.py. The problem is resolved.

tk0miya commented 6 years ago

:-)