Repository: pandas-dev/pandas

Issue:
Missing dependency for sphinxcontrib-spelling
```
(pandas-dev) [mgarcia@xps doc]$ python make.py --num-jobs=8
Running Sphinx v1.7.5

Extension error:
Could not import extension sphinxcontrib.spelling (exception: No module named 'sphinxcontrib.spelling')
```
#### Problem description

In #21109 the package `sphinxcontrib-spelling` has been added to the sphinx configuration, but the package has not been included in the `conda` or `pip` dependencies. This is making the documentation script crash.



Discussion:
Seems like `sphinxcontrib-spelling` is available in conda and pip, but it requires `pyenchant` which is not available in the main channels of conda. Also, the versions I found seem to be conflicting with `pyarrow`.

@FabioRosado can you please provide more information on which dependencies you installed (which versions) and from which channels?
Hello @datapythonista, I forgot to add the requirements on the txt file my apologies.
I don't use conda so when I installed the sphinx extension all I did was `pip install sphinxcontrib-spelling` and everything worked fine, I got no conflicts with pyarrow when I tried to install the library.

As for pyenchant not being available in the main channels of conda, I tried running the spelling extension without pyenchant installed and everything worked fine - which is odd since the documentation says it uses pyenchant to produce a report showing misspelt words.  Perhaps if pyenchant is not installed the extension will just write the misspelt words on a text file?
Thanks for the info @FabioRosado, and no worries for the missing requirements. It was a cool and complex PR, easy to forget some detail.

I'd say that you had already `pyenchant` installed, or that `pip` installs it when installing `sphinxcontrib-spelling`. I'm using `conda` and I get:

```
(pandas-dev) [mgarcia@xps doc]$ python make.py --num-jobs=8
Running Sphinx v1.7.5

Extension error:
Could not import extension sphinxcontrib.spelling (exception: No module named 'enchant')
```
Yeah my bad I forgot to activate the virtualenv that's why it wasn't showing on my pip list haha

I don't use conda so I'm not sure if there is a workaround this issue. It seems you can download the pyenchant file, could this be a possible solution? Also, not sure if it matters but pyenchant is now unmaintained
Yes, I had this problem yesterday as well. The conda-forge package is kind of broken as it does not install the needed dependencies. But it also seems that `pyenchant` is no longer maintainted.
Given the install problems, maybe we should make the package optional? (so in `conf.py` try to import it, and only if it is importable, add it to the list of extensions?)
BTW, this also broke our travis doc build, since it is of course needed there as well.
let’s revert this for now
leave the actual spelling fixes of course
No need to revert I think, we can leave the `python make.py spelling` there, for if you have it installed. Just need a try except in conf.py
I will start working on Part 2 of this PR so I'll add the try there if its alright with everyone

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -16,9 +16,11 @@
 import re
 import inspect
 import importlib
-from sphinx.ext.autosummary import _import_by_name
+import logging
 import warnings
+from sphinx.ext.autosummary import _import_by_name
 
+logger = logging.getLogger(__name__)
 
 try:
     raw_input          # Python 2
@@ -73,9 +75,16 @@
               'sphinx.ext.ifconfig',
               'sphinx.ext.linkcode',
               'nbsphinx',
-              'sphinxcontrib.spelling'
               ]
 
+try:
+    import sphinxcontrib.spelling
+except ImportError as err:
+    logger.warn(('sphinxcontrib.spelling failed to import with error "{}". '
+                '`spellcheck` command is not available.'.format(err)))
+else:
+    extensions.append('sphinxcontrib.spelling')
+
 exclude_patterns = ['**.ipynb_checkpoints']
 
 spelling_word_list_filename = ['spelling_wordlist.txt', 'names_wordlist.txt']


Test patch: