Configuring Sphinx to use MyST?

878 views
Skip to first unread message

Bob DuCharme

unread,
Jun 30, 2023, 10:29:08 AM6/30/23
to sphinx-users
I have installed sphinx and can run sphinx-build fine, and I have installed MyST and can run myst-docutils-demo fine. When I add 'myst_parser' to the Sphinx conf.py extensions list, though, sphinx-build gives me "Could not import extension myst_parser (exception: No module named 'myst_parser')." What am I missing?

Thanks,

Bob

jdsalaro

unread,
Jul 4, 2023, 8:43:52 AM7/4/23
to sphinx-users

This doesn't sound right.
How and where have you installed the Myst parser?
Do you use virtual environments for easier debugging?
I would guess myst-parser is not installed where you think it is and therefore sphinx cannot find it.
As always on the internet, it's easier to get help if you provide the steps and output you were getting.
This works flawlessly for me every time:

-----------------------------------------------------------------------------------------------------------------------------------------------------

 $ mkdir mystparser

 $ cd mystparser/

 $ pipenv install sphinx myst-parser

 $ pipenv shell

$ vim conf.py

(mystparser)$ cat conf.py
 
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'test'
copyright = '2023, test'
author = 'test'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['myst_parser']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']

$ sphinx-build . _build

Running Sphinx v7.0.1
loading pickled environment... done
myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
reading sources...
looking for now-outdated files... none found
no targets are out of date.
build succeeded.

The HTML pages are in _build.

-----------------------------------------------------------------------------------------------------------------------------------------------------



Bob DuCharme

unread,
Jul 31, 2023, 4:28:01 PM7/31/23
to sphinx-users
(My apologies for the long delay in replying.) We are using venv to create and use a virtual environment called _venv. I won't post the entire scripts that we use to install and run sphinx, but after doing them I get a successful build. After then doing pip install myst-parser, I see the myst files in _venv/bin, but when I run the build script at that point I get this:

Could not import extension sphinxcontrib.plantuml (exception: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/bob/git/documentation/_venv/lib/python3.10/site-packages/sphinx/util/osutil.py))

Running pip install plantuml shows that it's already installed. 

My goal is to enable myst usage in a Sphinx environment that was up and working before I got here, so installing myst in a simplified sphinx environment is not an option. I'm just hoping that the error message above might look familiar to someone. 

Thanks,

Bob

Ulysses Simmons

unread,
Jul 31, 2023, 8:21:04 PM7/31/23
to sphinx...@googlegroups.com
Thank you for your email.

--
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/20f0bb2c-d081-495a-8aeb-4e48886a6f31n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages