1

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)
0

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

1 Comment

Exactly . I got the same error -> AttributeError: partially initialized module 'jsondiff' has no attribute 'diff' (most likely due to a circular import). This solves the issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.