1

this error occures when i try to add data into excel sheet, it works very well with to_csv but not with to_excel so anyone knows what can i do?

this is a piece of the code when i try to add the data of the list 'results':

lis=pd.DataFrame(results)
lis.to_csv('lis.csv')
lis.to_excel('lis.xlsx')

Error:

Traceback (most recent call last):
  File "C:\Users\pagination.py", line 26, in <module>
    lis.to_excel('lis.xlsx')
  File "C:\Users\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py", line 2345, in to_excel
    formatter.write(
  File "C:\Local\Programs\Python\Python310\lib\site-packages\pandas\io\formats\excel.py", line 888, in write
    writer = ExcelWriter(  # type: ignore[abstract]
  File "C:\Users\Tasnem\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\excel\_openpyxl.py", line 49, in __init__
    from openpyxl.workbook import Workbook
ModuleNotFoundError: No module named 'openpyxl'
  • You have to learn how to read the error messages, it's self-explanatory: **ModuleNotFoundError: No module named 'openpyxl'** – mozway Sep 29 '22 at 11:32

0 Answers0