0

I am getting this error while running the below command:-

  • Python version=3.10.8
  • Django version=2.1
  • openpyxl=2.6.2

python manage.py runserver 127.0.0.1:8000

Error:-

    Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x118793400>
Traceback (most recent call last):
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/__init__.py", line 3, in <module>
    from tablib.core import (
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/core.py", line 15, in <module>
    from tablib import formats
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/__init__.py", line 12, in <module>
    from . import _xlsx as xlsx
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/_xlsx.py", line 14, in <module>
    import openpyxl
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/__init__.py", line 6, in <module>
    from openpyxl.workbook import Workbook
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/__init__.py", line 5, in <module>
    from .workbook import Workbook
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/workbook.py", line 8, in <module>
    from openpyxl.worksheet.worksheet import Worksheet
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/worksheet/worksheet.py", line 30, in <module>
    from openpyxl.cell import Cell, MergedCell
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/__init__.py", line 4, in <module>
    from .cell import Cell, WriteOnlyCell, MergedCell
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/cell.py", line 52, in <module>
    from openpyxl.styles.styleable import StyleableObject
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/styleable.py", line 11, in <module>
    from .builtins import styles
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/builtins.py", line 1347, in <module>
    ('Normal', NamedStyle.from_tree(fromstring(normal))),
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/common.py", line 113, in fromstring
    parser = DefusedXMLParser(target=_TreeBuilder(),
  File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/ElementTree.py", line 68, in __init__
    _XMLParser.__init__(self, html, target, encoding)
TypeError: XMLParser.__init__() takes 1 positional argument but 4 were given

I couldn't understand the exact issue behind this, If anyone has an idea how to resolve, please feel free share his/her suggestions.

jademaddy
  • 99
  • 7

2 Answers2

0

pandas.read_excel raises TypeError: __init__() takes 1 positional argument but 4 were given

Suggested by the above's issues answer, I tried upgrading openpyxl.

However, I was also still having this issue after upgrading openpyxl, turns out I have an outdated defusedxml package installed. After upgrading that to the most recent version (0.7.1 as of today), I no longer have this issue.

chmnata
  • 74
  • 4
-1

The html argument of XMLParser() is deprecated in python3.7. You must to upgrade openpyxl to a newest version (at least 3.0.0):

https://openpyxl.readthedocs.io/en/stable/changes.html#id80

LaCharcaSoftware
  • 1,075
  • 1
  • 5
  • 13