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)
Joshua Varghese
  • 5,082
  • 1
  • 13
  • 34
Rusty
  • 113
  • 1
  • 7

1 Answers1

7

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

Joshua Varghese
  • 5,082
  • 1
  • 13
  • 34
mustafasencer
  • 723
  • 4
  • 12