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:MeIdeaProjectssrcapp
epositoriesuser_repository.py", line 14, in get_user
user = 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 dct
json.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)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…