Reputation: 113
I am running Windows 10 with MS Code Python 3.7
I get the following message from my simple code block
Traceback (most recent call last):
File "c:/Users/marke/OneDrive/Desktop/Python Tutorial/json.py", line 1, in module import json File "c:\Users\marke\OneDrive\Desktop\Python Tutorial\json.py", line 6, in jsText = json.loads(FileText) AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to a circular import)
My code
import json
jsFile = open("myjson.json","r")
FileText = jsFile.read
jsText = json.loads(FileText)
Upvotes: 1
Views: 7010
Reputation: 763
When you name your script the name of the module you try to import, python tries to imports your script first, which results in the Error
Upvotes: 9