Skip to content

NameError: name 'ALLOWED_STYLES' is not defined on import #2209

@auxym

Description

@auxym

nbconvert version 7.16.6

Python 3.12.7

Simply importing nbconvert produces the following stack trace:

❯ python -m nbconvert
C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\filters\strings.py:23: UserWarning: The installed bleach/tinycss2 do not provide CSS sanitization, please upgrade to bleach >=5
  from nbconvert.preprocessors.sanitize import _get_default_css_sanitizer
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\__init__.py", line 6, in <module>
    from . import filters, postprocessors, preprocessors, writers
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\filters\__init__.py", line 8, in <module>
    from .markdown import (
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\filters\markdown.py", line 16, in <module>
    from .markdown_mistune import markdown2html_mistune
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\filters\markdown_mistune.py", line 21, in <module>
    from nbconvert.filters.strings import add_anchor
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\filters\strings.py", line 23, in <module>
    from nbconvert.preprocessors.sanitize import _get_default_css_sanitizer
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\preprocessors\sanitize.py", line 48, in <module>
    class SanitizeHTML(Preprocessor):
  File "C:\Users\thef2102\source\mrfsplus_code\data analysis\.venv\Lib\site-packages\nbconvert\preprocessors\sanitize.py", line 66, in SanitizeHTML
    default_value=ALLOWED_STYLES,  # type:ignore[arg-type]
                  ^^^^^^^^^^^^^^
NameError: name 'ALLOWED_STYLES' is not defined. Did you mean: 'ALLOWED_TAGS'?

The bleach warning is odd, as it says to install bleach > 5, yet I have 6.2.0 installed.

❯ python
Python 3.12.7 (tags/v3.12.7:0b05ead, Oct  1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bleach
>>> bleach.__version__
'6.2.0'
>>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions