I am creating an Excel file with two sheets from 2 different data frames. Here is a sample code:
import pandas as pd
import openpyxl
import xlsxwriter
with pd.ExcelWriter('output.xlsx',engine='xlsxwriter') as wr:
df1.to_excel(wr, sheet_name='Final',index=False)
df2.to_excel(wr, sheet_name='Tie_Line_Data',index=False)
When I run it in any Python IDE, it runs perfectly. However, when I run it in Terminal, it gives the following error:
Traceback (most recent call last):
File "/home/memiit/public_html/Pooja_MemiIT_Server/weather_demand_data_automated_mail.py", line 382, in <module>
with pd.ExcelWriter('output.xlsx',engine='xlsxwriter') as wr:
File "/home/memiit/public_html/python3/lib/python3.6/site-packages/pandas/io/excel/_xlsxwriter.py", line 187, in __init__
self.book = xlsxwriter.Workbook(path, **engine_kwargs)
AttributeError: module 'xlsxwriter' has no attribute 'Workbook'
How do I solve this, or is there any alternative way of doing it.