Previos title was:
AttributeError: module 'json' has no attribute 'loads'
I changed it because it looks similar to this but at the link that i provided, the problem seems that the person was having a file called json.py
that was tricking the import to think that is importing a local file and not the json from standard library. My problem is that I don't have any local file called json.py
;
I am wondering if it has to do anything related to PATH or the structure of my project. Any suggestion might help.
error traceback:
File "D:\Me\IdeaProjects\src\app\repositories\user_repository.py", line 14, in get_useruser = json.loads(file.read())
I am running the code in Windows 10, and intelliJ ide.
Python version: 3.7.4
Tried the code from the official documentation this:
import json
def as_complex(dct):if '__complex__' in dct:return complex(dct['real'], dct['imag'])return dctjson.loads('{"__complex__": true, "real": 1, "imag": 2}', object_hook=as_complex)
And got this error as well:
Traceback (most recent call last):File "<pyshell#7>", line 1, in <module>json.loads('{"__complex__": true, "real": 1, "imag": 2}',object_hook=as_complex)
AttributeError: module 'json' has no attribute 'loads'
When I try to import loads
explicitly i get this error:
ImportError: cannot import name 'loads' from 'json' (unknown location)