0
votes

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

5

5 Answers

4
votes

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.

2
votes

also change

from pandas.io.json.normalize

to

from pandas.io.json._normalize

0
votes

The cause of the problem was the fact that the python file had the name pandas. The filename was pandas.py. After renaming it, the code worked normally without errors.

0
votes

I facing the same problem as well whe I running my python code in Python 3.7. But, when I change it into Python 2.7, my python code is runs smoothly. So maybe you can change your python version from 3.7 into 2.7

I hope it help

0
votes

i had same problem and i solve it b uninstalling extra python versions install on my windows.now i have only one python installed by anaconda,and everything is working perfectly