Search code examples
jinja2pandas-profiling

Unable to import pandas_profiling module, because of 'escape' from jinja2.utils dependency


from pandas_profiling import profile_report

=================================================

ImportError: cannot import name 'escape' from 'jinja2.utils' (/opt/conda/lib/python3.7/site-packages/jinja2/utils.py)


Solution

  • It seems that escape module was dropped from newer versions of jinja2. The newer versions of pandas-profiling use markupsafe to import escape module (from markupsafe import escape). However, your version seems to already use the old import (from jinja2.utils import escape). You have two options:

    • Try to install a newer version of pandas-profiling.
    • Or install an older version of jinja2.

    The following environment seems to be working:

    Jinja2                3.1.1
    MarkupSafe            2.0.1
    numpy                 1.22.3
    pandas                1.4.2
    pandas-profiling      3.1.0
    

    Check this post, or this github issue for more information.