Search code examples
pandasnormalize

ModuleNotFoundError: No module named 'pandas.io' for json_normalize


Please read carefully. In my Python script I have the following:

import json 
import pandas
from pandas.io.json import json_normalize

and it returns the following error:

from pandas.io.json import json_normalize ModuleNotFoundError: No module named 'pandas.io'; 'pandas' is not a package

My steps:

  • I have uninstalled and installed Pandas
  • I have upgraded pip and pandas
  • I have installed io (pip install -U pandas.io)
  • I have installed data_reader and replaced the pandas.io.json part with that: from pandas_datareader import json_normalize

I have tried every solution I saw on stackoverflow and github and nothing worked. The only one I have not tried is installing Anaconda but it should work with what I tried before. Do you think it is a Windows setting things I must change?

PS: My Python version is 3.7.4


Solution

  • Try:

    Go to ...\Lib\site-packages\pytrends on your local disk and open file request.py

    Change

    from pandas.io.json._normalize import nested_to_record
    

    to

    from pandas.io.json.normalize import nested_to_record
    

    I had the same error, but it helped me.