Extensions not working... ModuleNotFoundError: No module named 'sphinx_rtd_theme'

129 views
Skip to first unread message

Beat Gurtner

unread,
May 26, 2020, 11:44:27 AM5/26/20
to sphinx-users

After switch to a new macbook (Mac OS Catalina), my sphinx scripts are not working anymore:

Sphinx v3.0.3 in Verwendung

Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/usr/local/Cellar/sphinx-doc/3.0.3/libexec/lib/python3.8/site-packages/sphinx/config.py", line 319, in eval_config_file
    execfile_(filename, namespace)
  File "/usr/local/Cellar/sphinx-doc/3.0.3/libexec/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 81, in execfile_
    exec(code, _globals)
  File "/Applications/MAMP/htdocs/sakkadentrainer/doc/conf.py", line 43, in <module>
    import sphinx_rtd_theme
ModuleNotFoundError: No module named 'sphinx_rtd_theme'

I have installed the module sphinx_rtd_theme with:

pip3 install rst2pdf

Requirement already satisfied: rst2pdf in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (0.97)
Requirement already satisfied: jinja2 in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (2.11.2)
Requirement already satisfied: pygments in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (2.6.1)
Requirement already satisfied: pdfrw in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (0.4)
Requirement already satisfied: smartypants in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (2.0.1)
Requirement already satisfied: setuptools in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages (from rst2pdf) (40.8.0)
Requirement already satisfied: docutils in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (0.16)
Requirement already satisfied: six in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages (from rst2pdf) (1.12.0)
Requirement already satisfied: reportlab in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from rst2pdf) (3.5.42)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from jinja2->rst2pdf) (1.1.1)
Requirement already satisfied: pillow>=4.0.0 in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (from reportlab->rst2pdf) (7.1.2)
You are using pip version 19.0.3, however version 20.2b1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-20.2b1-py2.7.egg (20.2b1)

I think it has nothing to do with the sphinx_rtd_theme itself, because if I comment this theme in conf.py I get the next error:

Could not import extension rst2pdf.pdfbuilder (exception: No module named 'rst2pdf')

But if I comment all extensions the script works without error:

sphinx-build -D language=de -b html /Applications/MAMP/htdocs/sakkadentrainer/doc/ /Applications/MAMP/htdocs/sakkadentrainer_medical_doc/de/
Sphinx v3.0.3 in Verwendung
Lade Übersetzungen [de]…erledigt
loading pickled environment... failed
Fehlgeschlagen: 'str' object has no attribute '__dict__'
building [mo]: targets for 1 po files that are out of date
writing output... [100%] locale/de/LC_MESSAGES/settings_general.mo                                                                     
building [html]: targets for 23 source files that are out of date
updating environment: [new config] 23 added, 0 changed, 0 removed
reading sources... [100%] train                                                                                                        
/Applications/MAMP/htdocs/sakkadentrainer/doc/medical_product.rst:: WARNING: image file not readable: img/konferkl_signed.png
looking for now-outdated files... none found
pickling environment... erledigt
checking consistency... erledigt
preparing documents... erledigt
writing output... [100%] train                                                                                                         
generating indices...  genindexerledigt
writing additional pages...  searcherledigt
copying images... [100%] img/de/train_07.png                                                                                           
copying static files... ... erledigt
copying extra files... erledigt
dumping search index in German (code: de)... erledigt
dumping object inventory... erledigt
build abgeschlossen, 1 warning.

The HTML pages are in ../../sakkadentrainer_medical_doc/de.

Answer from github:

I think this problem is caused by your environment. Please check your python.

Sphinx is installed under /usr/local/Celler.

File "/usr/local/Cellar/sphinx-doc/3.0.3/libexec/lib/python3.8/site-packages/sphinx/config.py", line 319, in eval_config_file

But your pip3 refers /Users/beatgurtner/Library/Python.

Requirement already satisfied: rst2pdf in /Users/beatgurtner/Library/Python/3.7/lib/python/site-packages (0.97)

I guess you installed multiple pythons in your PC. Please install sphinx_rtd_theme into the Python that Sphinx installed.





My response:



Yes, I have standard python 2.7 and 3.7

python --version
Python 2.7.16
which python
/usr/bin/python
which python3
/usr/bin/python3
python3 --version
Python 3.7.3

I think for sphinx python 2.7 is enough...

So how can I tell my system and sphinx to use 2.7?

Do I have to change something in $PATH?

echo $PATH
/usr/local/opt/sphinx-doc/bin:/usr/local/opt/sphinx-doc/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Thanks for the help and sorry but for me this is all a bit of a mess ;)

Matthias Geier

unread,
May 26, 2020, 12:17:32 PM5/26/20
to sphinx...@googlegroups.com
Hi Beat.

I prefer to invoke all Python-based tools with the same executable.
For example, instead of using "pip" or "pip3" (or who knows what), I use:

python3 -m pip install sphinx_rtd_theme

And the same thing for "sphinx-build":

python3 -m sphinx <source-dir> <build-dir>

More concretely, this could be:

python3 -m sphinx doc html-files

If you do it this way, you always know which Python version is used.

You can be even more specific and include the minor version if you want:

python3.8 -m ...

HTH.

cheers,
Matthias
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/d2828d67-9cec-41ab-a2d8-f4cc79e6200a%40googlegroups.com.

Beat Gurtner

unread,
May 26, 2020, 12:31:13 PM5/26/20
to sphinx-users
Thanks.

Also also tried this, but It did not work:

python3 -m sphinx-build -D language=de -b html /Applications/MAMP/htdocs/sakkadentrainer/doc/ /Applications/MAMP/htdocs/sakkadentrainer_medical_doc/de/

/Users/beatgurtner/.pyenv/versions/3.7.1/bin/python3: No module named sphinx-build




Since the last post i tried to install pyenv to try to reduce the mess ;)


I can now switch the python --version from 2.7.16 to 3.7.1


But I'm not sure if this really helps...


If I use pyenv and use python 2.7.16 then this command should work:


sphinx-build -D language=de -b html /Applications/MAMP/htdocs/sakkadentrainer/doc/ /Applications/MAMP/htdocs/sakkadentrainer_medical_doc/de/


but I get an error:


dyld: Library not loaded: @executable_path/../.Python

  Referenced from: /usr/local/Cellar/sphinx-doc/3.0.3/libexec/bin/python3.8

  Reason: image not found

zsh: abort      sphinx-build -D language=de -b html 

> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx...@googlegroups.com.

Matthias Geier

unread,
May 26, 2020, 1:05:49 PM5/26/20
to sphinx...@googlegroups.com
Hi Beat.

Python is right, there is "No module named sphinx-build".

As I mentioned in my previous e-mail, you should use

python3 -m sphinx ...

cheers,
Matthias
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/8c26b63c-132b-4cb2-965e-a1b8236bb583%40googlegroups.com.

Beat Gurtner

unread,
May 27, 2020, 3:58:34 AM5/27/20
to sphinx-users
Hi,

I already tried that, did not work...

But I think I have solved by using the correct paht for pip to install the extensions:

/usr/local/opt/python@3.8/bin/pip3 install 


echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.zshrc


and add python3.8 to $path

just rst2pdf is not working with python3...

Matthias Geier

unread,
May 27, 2020, 10:21:27 AM5/27/20
to sphinx...@googlegroups.com
On Wed, May 27, 2020 at 9:58 AM Beat Gurtner wrote:
>
> I already tried that, did not work...

Can you please provide the exact commands you were using and the
resulting error messages?

cheers
Matthias
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/da6b6d66-8432-4eb9-a924-746611fe63e8%40googlegroups.com.

Hoang Tran

unread,
May 27, 2020, 2:57:36 PM5/27/20
to sphinx...@googlegroups.com
I don’t know exactly what configuration you have but just a suggestion, use ‘find’ command to locate where the 

__init__.py 

is located. I use ‘Finder’ on my MacBook and find them in 

/usr/local/lib/python3.7/site-packages

So set the PYTHONPATH environment variable to that in the .bashrc or whatever shell you’re using (ie. zshrc). Reload using 

. ~/.bashrc

Then do 

python3 -c ‘import sphinx; print(dir(sphinx))’

To test. 
Just a thought.
HDT

Reply all
Reply to author
Forward
0 new messages