Dear community,
I tried to open excel file with the engine openpyxl. I am getting one error - TypeError: __init__() takes 1 positional argument but 4 were given. Can you please tell me what should i do?
Please refer the error below -
df =pd.read_excel("C:\\Users\\SHAR8263\\Desktop\\check.xlsx", engine ='openpyxl')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-5a23dd753d78> in <module>
----> 1 df =pd.read_excel("C:\\Users\\SHAR8263\\Desktop\\check.xlsx", engine ='openpyxl')
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)
312
313 return wrapper
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\io\excel\_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, decimal, comment, skipfooter, convert_float, mangle_dupe_cols, storage_options)
455 if not isinstance(io, ExcelFile):
456 should_close = True
--> 457 io = ExcelFile(io, storage_options=storage_options, engine=engine)
458 elif engine and engine != io.engine:
459 raise ValueError(
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\io\excel\_base.py in __init__(self, path_or_buffer, engine, storage_options)
1417 self.storage_options = storage_options
1418
-> 1419 self._reader = self._engines[engine](self._io, storage_options=storage_options)
1420
1421 def __fspath__(self):
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\io\excel\_openpyxl.py in __init__(self, filepath_or_buffer, storage_options)
523 """
524 import_optional_dependency("openpyxl")
--> 525 super().__init__(filepath_or_buffer, storage_options=storage_options)
526
527 @property
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\io\excel\_base.py in __init__(self, filepath_or_buffer, storage_options)
516 self.handles.handle.seek(0)
517 try:
--> 518 self.book = self.load_workbook(self.handles.handle)
519 except Exception:
520 self.close()
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\pandas\io\excel\_openpyxl.py in load_workbook(self, filepath_or_buffer)
534 from openpyxl import load_workbook
535
--> 536 return load_workbook(
537 filepath_or_buffer, read_only=True, data_only=True, keep_links=False
538 )
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, keep_links)
315 reader = ExcelReader(filename, read_only, keep_vba,
316 data_only, keep_links)
--> 317 reader.read()
318 return reader.wb
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\openpyxl\reader\excel.py in read(self)
275 def read(self):
276 self.read_manifest()
--> 277 self.read_strings()
278 self.read_workbook()
279 self.read_properties()
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\openpyxl\reader\excel.py in read_strings(self)
142 strings_path = ct.PartName[1:]
143 with self.archive.open(strings_path,) as src:
--> 144 self.shared_strings = read_string_table(src)
145
146
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\openpyxl\reader\strings.py in read_string_table(xml_source)
13 STRING_TAG = '{%s}si' % SHEET_MAIN_NS
14
---> 15 for _, node in iterparse(xml_source):
16 if node.tag == STRING_TAG:
17 text = Text.from_tree(node).content
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\defusedxml\common.py in iterparse(source, events, parser, forbid_dtd, forbid_entities, forbid_external)
103 forbid_entities=True, forbid_external=True):
104 if parser is None:
--> 105 parser = DefusedXMLParser(target=_TreeBuilder(),
106 forbid_dtd=forbid_dtd,
107 forbid_entities=forbid_entities,
C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\defusedxml\ElementTree.py in __init__(self, html, target, encoding, forbid_dtd, forbid_entities, forbid_external)
66 forbid_external=True):
67 # Python 2.x old style class
---> 68 _XMLParser.__init__(self, html, target, encoding)
69 self.forbid_dtd = forbid_dtd
70 self.forbid_entities = forbid_entities
TypeError: __init__() takes 1 positional argument but 4 were given