使用wagtai的初始runserver上出现InvalidTemplateLibraryError

2024-04-16 15:46:24 发布

您现在位置:Python中文网/ 问答频道 /正文

每次我都这么做 python manage.py runserver 一个错误说

Invalid template library specified.

ImportError raised when trying to load 'wagtail.wagtailcore.templatetags.wagtailcore_tags': cannot import name _htmlparser


Tags: topymanage错误libraryloadtemplatewhen
2条回答

新版本的html5lib有一些bug。我找到了两种解决这个问题的方法:

  1. 降级html5lib(我尝试了版本0.9999999)

pip uninstall html5lib
pip install html5lib==0.9999999

降级后,一切似乎都很顺利。你知道吗

  1. 通过编辑beautifulsoup4包文件临时修复

<path_to_your_virtualenv>/lib/python2.7/site-packages/bs4/builder/__init__.py

在文件末尾,您需要注释掉下一行:

from . import _htmlparser
register_treebuilders_from(_htmlparser)
try:
    from . import _html5lib
    register_treebuilders_from(_html5lib)
except ImportError:
    # They don't have html5lib installed.
    pass

在你把它们注释掉之后,摇摆就开始了。你知道吗

另外,我更喜欢第一种选择。

编辑1:

发现打开的GitHub问题:https://github.com/html5lib/html5lib-python/issues/276

您也可以将其添加到您的需求项目文件中,即:

wagtail==1.3.1
html5lib==0.9999999

相关问题 更多 >