AttributeError: модуль 'xml.etree.ElementTree' не имеет атрибута '_IterParseIterator'

Я использую Python v3.8.5 и Django v3.2.6. Когда я набираю в "models.py" этот код :

image = models.ImageField(null=True, blank=True)

Но это были шоу :

AttributeError: module 'xml.etree.ElementTree' has no attribute '_IterParseIterator'.

Полная ошибка:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 393, in execute
    self.check()
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 419, in check
    all_issues = checks.run_checks(
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\model_checks.py", line 34, in check_all_models
    errors.extend(model.check(**kwargs))
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 1271, in check
    *cls._check_fields(**kwargs),
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\base.py", line 1382, in _check_fields
    errors.extend(field.check(**kwargs))
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\fields\files.py", line 384, in check
    *self._check_image_library_installed(),
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\fields\files.py", line 389, in _check_image_library_installed
    from PIL import Image  # NOQA
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\PIL\Image.py", line 43, in <module>
    import defusedxml.ElementTree as ElementTree
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\defusedxml\ElementTree.py", line 62, in <module>
    _XMLParser, _iterparse, _IterParseIterator, ParseError = _get_py3_cls()
  File "C:\Users\dhibh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\defusedxml\ElementTree.py", line 56, in _get_py3_cls
    _IterParseIterator = pure_pymod._IterParseIterator
AttributeError: module 'xml.etree.ElementTree' has no attribute '_IterParseIterator'

Почему я получаю эту ошибку? Заранее спасибо.

Я думаю, что вы используете старую версию зависимости defusedxml. Попробуйте запустить:

pip install --upgrade defusedxml

Вернуться на верх