Asit Patel
Asit Patel

Reputation: 1

no able to open .xlsx file using openpyxl in VS code . Gives error as shown

PS C:\Users\Asit\Desktop\python> python -u "c:\Users\Asit\Desktop\python\excel_project\excel.py"
Traceback (most recent call last):
  File "c:\Users\Asit\Desktop\python\excel_project\excel.py", line 3, in <module>
    wb = xl.load_workbook('transactions.xlsx')
  File "C:\Users\Asit\AppData\Local\Programs\Python\Python313\Lib\site-packages\openpyxl\reader\excel.py", line 346, in load_workbook
    reader = ExcelReader(filename, read_only, keep_vba,
                         data_only, keep_links, rich_text)
  File "C:\Users\Asit\AppData\Local\Programs\Python\Python313\Lib\site-packages\openpyxl\reader\excel.py", line 123, in __init__
    self.archive = _validate_archive(fn)
                   ~~~~~~~~~~~~~~~~~^^^^
  File "C:\Users\Asit\AppData\Local\Programs\Python\Python313\Lib\site-packages\openpyxl\reader\excel.py", line 95, in _validate_archive
    archive = ZipFile(filename, 'r')
  File "C:\Users\Asit\AppData\Local\Programs\Python\Python313\Lib\zipfile\__init__.py", line 1362, in __init__
    self.fp = io.open(file, filemode)
              ~~~~~~~^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'transactions.xlsx'

Despite being in the same folder, it's showing a file not found error. I tried using the absolute path and putting them in different folders, but it's not working.

Upvotes: 0

Views: 50

Answers (0)

Related Questions