Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
auxym opened this issue Feb 26, 2025 · 0 comments
Open

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

auxym opened this issue Feb 26, 2025 · 0 comments

Comments

@auxym
Copy link

auxym commented Feb 26, 2025

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'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant