Cannot import name 'soft_unicode' from 'markupsafe' in google colab

Question:

I’m trying to install pycaret==3.0.0 in google colab, But I’m having a problem, the library requires Jinja2 to be installed which I did, but then It finally throws off another error.

ImportError                               Traceback (most recent call last)
<ipython-input-26-4f8843d24b3a> in <module>()
----> 1 import jinja2
      2 from pycaret.regression import *

3 frames
/usr/local/lib/python3.7/dist-packages/jinja2/filters.py in <module>()
     11 from markupsafe import escape
     12 from markupsafe import Markup
---> 13 from markupsafe import soft_unicode
     14 
     15 from ._compat import abc

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/root/.local/lib/python3.7/site-packages/markupsafe/__init__.py)
Asked By: Kalu Samuel

||

Answers:

Can you try this. This will install the latest release of pycaret and should take care of all dependencies for you. Just remember to restart the kernel after installation for the install to take effect correctly.

pip install -U --pre pycaret
Answered By: Nikhil Gupta

This is caused by upgrade in MarkupSafe:2.1.0 where they have removed soft_unicode, try using:

pip install markupsafe==2.0.1
Answered By: Andres S

Try this:

pip install markupsafe==2.1.1
conda update jupyter
Answered By: Cyrille edzang

I did the following to solve the same issue:

pip install -U markupsafe

so that I can use the latest version. I also had to update jinja2 with the same type of command.

Answered By: Robert Horn
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.