AttributeError: partially initialized module ‚json‘ has no attribute ‚load‘


sysvorOrt /home/michi/programmierung/python # python dictonary-speichern.py
Traceback (most recent call last):
File "/home/michi/programmierung/python/dictonary-speichern.py", line 3, in
import json
File "/home/michi/programmierung/python/json.py", line 6, in
daten = json.load(jsonfile)
AttributeError: partially initialized module 'json' has no attribute 'load' (most likely due to a circular import)
^^^^^^^^^


AttributeError: partially initialized module ‚json‘ has no attribute ‚load‘ (most likely due to a circular import)

Du hast eine Datei namens json.py in deinem Projektordner. Dadurch überschreibst du das eingebaute Python-Modul json und bekommst diesen Fehler:
AttributeError: partially initialized module 'json' has no attribute 'load' (most likely due to a circular import)

.

Lösung:
Benenne deine eigene Datei json.py um (zum Beispiel in myjson.py) und lösche eventuell die zugehörige json.pyc-Datei.
Danach funktioniert der Import von Python’s Standard-json-Modul wieder korrekt.

Schreibe einen Kommentar