Forums

AttributeError: module 'pandas' has no attribute 'json_normalize'

I'm using json_normalize in my code but it throws me an error: AttributeError: module 'pandas' has no attribute 'json_normalize'. How to fix this? I have updated pandas and also import pandas. I even did from pandas.io.json import json_normalize. It's not working. Really appreciate your help.

can you check what version of pandas you are running?

It's a bit hard to answer your question as it works on my end. I can import json_normalize by typing from pandas.io.json import json_normalize. I am also curious concerning the version of Pandas you are running. But as you state that you have updated Pandas you should have the latest version?

There are multiple versions of packages pre-installed on PythonAnywhere. See https://www.pythonanywhere.com/batteries_included/ You can also install your own version in virtual environment or with --user flag. See https://help.pythonanywhere.com/pages/InstallingNewModules/

I have the same issue. Why is the latest version of pandas not the default version on the platform? Why is Python2.7 with all its deprecated issues still the base version?

I am now trying:

when I run: python3.8 test_program.py

I get:

  :::python
  raceback (most recent call last):
  File "test_program.py", line 151, in <module>
    prods = prods.append(pd.json_normalize(data['items']), ignore_index=True)
  File "/usr/lib/python3.8/site-packages/pandas/__init__.py", line 214, in __getattr__
    raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
**AttributeError: module 'pandas' has no attribute 'json_normalize'**

Attempted to install pandas

pip3.6 install --user pandas

Looking in links: /usr/share/pip-wheels
Requirement already satisfied: pandas in /usr/lib/python3.6/site-packages (0.25.2)
Requirement already satisfied: pytz>=2017.2 in /usr/lib/python3.6/site-packages (from pandas) (2019.3)
Requirement already satisfied: python-dateutil>=2.6.1 in /usr/lib/python3.6/site-packages (from pandas) (2
.8.0)
Requirement already satisfied: numpy>=1.13.3 in /usr/lib/python3.6/site-packages (from pandas) (1.17.3)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.6/site-packages (from python-dateutil>=2.6.1->
pandas) (1.12.0)

No go. Now what?

You tried to install pandas in Python 3.6, but you're running it in Python 3.8. Also you may want to specify that you want to upgrade pandas with:

pip3.6 install --user -U pandas