pycaret
pycaret copied to clipboard
[INSTALL]: ImportError for 'Jinja2' when importing pycaret.classification
pycaret version checks
-
[X] I have checked that this issue has not already been reported here.
-
[X] I have confirmed this bug exists on the latest version of pycaret.
-
[ ] I have confirmed this bug exists on the master branch of pycaret (pip install -U git+https://github.com/pycaret/pycaret.git@master).
Issue Description
While running the binary classification tutorial (CLF101)
https://github.com/pycaret/pycaret/blob/master/tutorials/Binary%20Classification%20Tutorial%20Level%20Beginner%20-%20%20CLF101.ipynb, I came across an issue while importing pycaret.classification where 'Jinja2' was a missing dependency.
!pip install jinja2
doesn't seem to resolve the issue.
A working solution is running the code !pip install markupsafe==2.0.1
that seems to resolve the issue at hand.
The latest version of Pycaret needs to incorporate the missing dependency 'Jinja2'.
Reproducible Example
!pip install pycaret
from pycaret.utils import enable_colab
enable_colab()
from pycaret.datasets import get_data
dataset = get_data('credit')
dataset.shape
data = dataset.sample(frac=0.95, random_state=786)
data_unseen = dataset.drop(data.index)
data.reset_index(inplace=True, drop=True)
data_unseen.reset_index(inplace=True, drop=True)
print('Data for Modeling: ' + str(data.shape))
print('Unseen Data For Predictions: ' + str(data_unseen.shape))
from pycaret.classification import *
exp_clf101 = setup(data = data, target = 'default', session_id=123)
Expected Behavior
from pycaret.classfication import *
should run without errors.
Actual Results
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-537c6797760f> in <module>()
----> 1 from pycaret.classification import *
2 exp_clf101 = setup(data = data, target = 'default', session_id=123)
5 frames
/usr/local/lib/python3.7/dist-packages/pycaret/classification.py in <module>()
8 import numpy as np
9
---> 10 import pycaret.internal.tabular
11 from pycaret.loggers.base_logger import BaseLogger
12 from pycaret.parallel import ParallelBackend
/usr/local/lib/python3.7/dist-packages/pycaret/internal/tabular.py in <module>()
14 get_estimator_from_meta_estimator,
15 )
---> 16 from pycaret.internal.pipeline import (
17 add_estimator_to_pipeline,
18 get_pipeline_estimator_label,
/usr/local/lib/python3.7/dist-packages/pycaret/internal/pipeline.py in <module>()
9 # This pipeline is only to be used internally.
10
---> 11 from pycaret.internal.utils import get_all_object_vars_and_properties, is_fit_var
12 import imblearn.pipeline
13 from sklearn.utils import _print_elapsed_time
/usr/local/lib/python3.7/dist-packages/pycaret/internal/utils.py in <module>()
8 from pycaret.containers.models.base_model import ModelContainer
9 import pandas as pd
---> 10 import pandas.io.formats.style
11 import ipywidgets as ipw
12 from IPython.display import display, HTML, clear_output, update_display
/usr/local/lib/python3.7/dist-packages/pandas/io/formats/style.py in <module>()
47 from pandas.io.formats.format import save_to_buffer
48
---> 49 jinja2 = import_optional_dependency("jinja2", extra="DataFrame.style requires jinja2.")
50
51 from pandas.io.formats.style_render import (
/usr/local/lib/python3.7/dist-packages/pandas/compat/_optional.py in import_optional_dependency(name, extra, errors, min_version)
116 except ImportError:
117 if errors == "raise":
--> 118 raise ImportError(msg) from None
119 else:
120 return None
ImportError: Missing optional dependency 'Jinja2'. DataFrame.style requires jinja2. Use pip or conda to install Jinja2.
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Installed Versions
Did you restart the kernel after installing? If you do not do that, it might be causing the issue.
Thank you for replying. I did restart the kernel but the problem still persists. The solution I found was running the code !pip install markupsafe==2.0.1
.
you can try this !pip install --pre pycaret
you can try this !pip install --pre pycaret
Yes, please try this. This is the latest version that will be released shortly.
The same thing happened with the anomalies detection module,
@VinayChaudhari1996 What version of pycaret are you using. Have you tried the latest version (3.0.0rc) and face the same issues?
you can try this !pip install --pre pycaret
Confirming that this problem seems to be fixed in colab, there there is a cuml warning for regression import
from pycaret.regression import *
WARNING:logs:No module named 'cuml'.
'cuml' is a soft dependency and not included in the pycaret installation. Please run: pip install cuml
to install.
Thanks for confirming @microprediction (Peter)!
@ShreySrivas @VinayChaudhari1996 We will close this for now as the issue is not reproducible from our side as well. Please file a new request if you continue to face issues.