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

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    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'


    Inspite of being in the same folder its showing file not found error
    I tried using absolute path and putting the in different folders. Its not working.

    Continue reading...

Compartilhe esta Página