Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.188s · 23.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.9s · import 0.164s · 24MB
22MB installed
● package 22MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
convert
✓ from m2r import convert
✗ import m2r; m2r.convert()
Direct import of convert function is correct; module-level call also works but less explicit.
parse_from_file
✓ from m2r import parse_from_file
Converts a Markdown file to RST string.
Convert a Markdown string to reStructuredText.
from m2r import convert
markdown_text = "# Hello\n\nThis is **Markdown**."
rst_text = convert(markdown_text)
print(rst_text)
m2r --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'm2r'
m2r is not installed.
ImportError: cannot import name 'convert' from 'm2r'
Outdated version (<0.2.0) where convert function existed under different name or not at all.
fixUpgrade m2r: pip install --upgrade m2r
AttributeError: 'NoneType' object has no attribute 'groups'
Incompatibility with newer versions of mistune (mistune>=2.0.0 changed API).
fixPin mistune to version <2.0.0: pip install 'mistune<2.0.0'
Upgrade
Version history
0.3.1latest on PyPI · released Nov 17, 2022
Audit
Dependencies
mistunerequiredMarkdown parsing engine (m2r wraps mistune)
docutilsrequiredreStructuredText processing