0

Error when trying to load data with module JSON

File "C:\Users\Harry Walia\Desktop\Python\json1.py", line 3, in <module>
    import json
  File "C:\Users\Harry Walia\Desktop\Python\json.py", line 13, in <module>
    json_obj = json.loads(data)
  AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to a 
   circular import)
NoName69
  • 172
  • 2
  • 14
  • 5
    Welcome! Please provide a [Minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of your code. – adamgy Jun 29 '20 at 02:14
  • 1
    You named your file `json.py` now it clashes with the built-in `json` library. – Klaus D. Jun 29 '20 at 02:38

2 Answers2

1

The most common reason for this error is that you have a file in your current working directory named "json.py". Python already has the JSON module installed, so just make sure you haven't named any of your files "json.py"

NoName69
  • 172
  • 2
  • 14
0

Python already has a built-in Json module, so you do not need to install it. Just head into your shell and type:

import json

And you'll have the JSON module!

Gavin Wong
  • 1,254
  • 1
  • 6
  • 15