neurobin/mdx_wikilink_plus

ImportError: cannot import name 'etree' from 'markdown.util'

emign opened this issue · 4 comments

emign commented

Hi,
I use mdc_wikilink_plus as a part of my mkdocs obsidian setup.
During the build process of mkdocs I get the following error:

File "/usr/local/lib/python3.10/site-packages/mkdocs_embed_file_plugins/plugin.py", line 11, in <module>
mkdocs    |     from mdx_wikilink_plus.mdx_wikilink_plus import WikiLinkPlusExtension
mkdocs    |   File "/usr/local/lib/python3.10/site-packages/mdx_wikilink_plus/__init__.py", line 4, in <module>
mkdocs    |     from .mdx_wikilink_plus import makeExtension
mkdocs    |   File "/usr/local/lib/python3.10/site-packages/mdx_wikilink_plus/mdx_wikilink_plus.py", line 25, in <module>
mkdocs    |     from markdown.util import etree
mkdocs    | ImportError: cannot import name 'etree' from 'markdown.util' (/usr/local/lib/python3.10/site-packages/markdown/util.py)

Is there any explanation for that behavior?

This is my requirements.txt

mkdocs-material
mkdocs-mermaid2-plugin
mkdocs-ezlinked-plugin
mkdocs-awesome-pages-plugin
mdx_breakless_lists
mkdocs-preview-links-plugin
mkdocs-embed-file-plugins
markdown
mkdocs_custom_fences
mkdocs-git-revision-date-localized-plugin
mkdocs-encryptcontent-plugin
mkdocs-simple-hooks
mkdocs-callouts
Mkdocs-exclude
mkdocs-thumbnails
mkdocs-custom-tags-attributes
mkdocs-tooltipster-links-plugin
mdx_wikilink_plus
obs2mk

This can easily be reproduced with this docker setup:

docker_etree_import.zip

emign commented

As a matter of fact this concerns two plugins, which import your library:

ezlinks and embed_file

Hello!
In waiting of a merge of my PR, I created a fork here : https://github.com/Mara-Li/mdx_wikilink_plus, and I published it to pip on the name of mdx_wikilink_plus_fork : https://pypi.org/project/mdx-wikilink-plus-fork/

You can install it using pip install mdx-wikilink-plus-fork.

I updated my package that have the package in dependencies, ie :

  • Custom Fences
  • Embed file
  • Preview links

Simply update your requirements will fix the problems.

emign commented

Embed File and Preview link use your wikilink fork ?
That's strange because I get the errors using exactly these in my setup (check requirements.txt in the docker zip folder)

embed file still pulls the unforked library release:

mkdocs    |   File "/usr/local/lib/python3.10/site-packages/mkdocs_embed_file_plugins/plugin.py", line 11, in <module>
mkdocs    |     from mdx_wikilink_plus.mdx_wikilink_plus import WikiLinkPlusExtension
mkdocs    |   File "/usr/local/lib/python3.10/site-packages/mdx_wikilink_plus/__init__.py", line 4, in <module>
mkdocs    |     from .mdx_wikilink_plus import makeExtension
mkdocs    |   File "/usr/local/lib/python3.10/site-packages/mdx_wikilink_plus/mdx_wikilink_plus.py", line 25, in <module>
mkdocs    |     from markdown.util import etree
mkdocs    | ImportError: cannot import name 'etree' from 'markdown.util' (/usr/local/lib/python3.10/site-packages/markdown/util.py)

EDIT: fixed it with

mkdocs-embed-file-plugins==1.4.0

in requirements.txt. I somehow assumed that not specifying the version number would fetch the latest one (I think it should, but maybe it's not due to caching)

1.4.1 is now on pypi.