trustin / sphinx-binary

Run Sphinx on Windows, Linux and OS X with a single-file standalone binary.
14 stars 10 forks source link

How to use Python modules (installed with PIP) #9

Closed manticore-projects closed 1 year ago

manticore-projects commented 3 years ago

Hi Trustin,

first of all, big thank you for providing this. I got a basic Sphinx documentation built and could access the HTML side easily. However, now I face a super hard time with using plugins and themes, e. g. javasphinx and sphinx-redactor-theme.

I have installed both via PIP and can see that it is available. I can run javasphinx separately from the shell.

However, when calling mvn site the bundled sphinx keeps complaining

[INFO] Running Sphinx; output will be placed in /home/are/Documents/src/jsqlformatter/target/site
Running Sphinx v3.4.3

Traceback (most recent call last):
  File "sphinx/config.py", line 326, in eval_config_file
  File "sphinx/util/pycompat.py", line 88, in execfile_
  File "/home/are/Documents/src/jsqlformatter/src/site/sphinx/conf.py", line 3, in <module>
    import sphinx_redactor_theme
ModuleNotFoundError: No module named 'sphinx_redactor_theme'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "sphinx/cmd/build.py", line 279, in build_main
  File "sphinx/application.py", line 219, in __init__
  File "sphinx/config.py", line 173, in read
  File "sphinx/config.py", line 339, in eval_config_file
sphinx.errors.ConfigError: There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "sphinx/config.py", line 326, in eval_config_file
  File "sphinx/util/pycompat.py", line 88, in execfile_
  File "/home/are/Documents/src/jsqlformatter/src/site/sphinx/conf.py", line 3, in <module>
    import sphinx_redactor_theme
ModuleNotFoundError: No module named 'sphinx_redactor_theme'

I have no idea about Python, but I believe the problem stems from the bundled Sphinx, which does not consider the local Python modules. How should I solve that please?

miurahr commented 1 year ago
  1. install your extensions using venv and pip
  2. copy your extension python library into _extensions folder
  3. configure _extensions as extension library folder in conf.py sys.path.append(os.path.abspath('_extensions'))
manticore-projects commented 1 year ago

Thank you much!