I'm trying to load JSON from a file into python, but I keep receiving the error:
AttributeError: module 'json' has no attribute 'load'
I don't have files called json.py in my directory like other answers suggested.
When I do:
import json;
print(json.__file__)
/usr/lib/python3.6/json/__init__.py
I receive:
/usr/lib/python3.6/json/init.py
I have checked the file and it does contain the methods.
The full script is:
#!/usr/bin/env python3
import json;
print(json.__file__)
import sys;
#a = json.load('["foo", {"bar":["baz", null, 1.0, 2]}]')
#pprint(a);
#sys.exit();
from pprint import pprint;
with open('services.json') as f:
data=json.load(f);
pprint(data);
I'm kinda losing my mind here. When I change the shebang to python2.7 it does work, however, I have written my other scripts with python3.6.
Help would be very much appreciated!
Solution: I named the file 'enum.py', changing the name removes the error.