cannot import name 'BaseModel' from 'pydantic' (unknown location)

2.5k views Asked by At

I was trying to import the library dataprep, and it looks like it has some problems.

The code was like this:

from dataprep.eda import plot
# plot_correlation,create_report,plot_missing

here is the error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[146], line 1
----> 1 from dataprep.eda import plot

File ~\anaconda3\lib\site-packages\dataprep\eda\__init__.py:8
      5 from bokeh.io import output_notebook
      7 from ..utils import is_notebook
----> 8 from .correlation import compute_correlation, plot_correlation, render_correlation
      9 from .create_report import create_report
     10 from .create_db_report import create_db_report

File ~\anaconda3\lib\site-packages\dataprep\eda\correlation\__init__.py:10
      7 import dask.dataframe as dd
      8 import pandas as pd
---> 10 from ..configs import Config
     11 from ..container import Container
     12 from ...progress_bar import ProgressBar

File ~\anaconda3\lib\site-packages\dataprep\eda\configs.py:23
     20 from __future__ import annotations
     22 from typing import Any, Dict, List, Optional, Tuple, Union
---> 23 from pydantic import BaseModel, Field
     24 from ..utils import is_notebook
     27 # This dictionary map the plot names in display to their canonicalized names in Config

ImportError: cannot import name 'BaseModel' from 'pydantic' (unknown location)

How do I resolve the error and successfully import the dataprep library?

1

There are 1 answers

0
semmyk-research On BEST ANSWER

How do I resolve the error and successfully import the dataprep library?

Without knowing your versions of pydantic and dataprep, you should consider the following:

  1. check your path. See similar discussion in this SO: Why i can't import BaseModel from Pydantic?
  2. update your version of dataprep, which should update pydantic as well (#dependencies). If pydantic is not updated, kindly update it manually with pip install -U pydantic or conda.
  3. raise an issue on dataprep github
  4. [not recommended] 'manually' edit the __init__.py in pydantic: check your ~\anaconda3\lib\site-packages\pydantic folder.

I had a similar error message earlier this week but from pygwalker. See this SO: PyGWalker: cannot import name 'Field' from 'pydantic'