pythonpython-3.xpandaspyinstallerpandas.excelwriter

pandas to_excel not working with pyinstaller


I'm making an exe from a python script using pyinstaller everything in the code works fine except for to_excel(). I've listed the imports and what exactly is not working when I make it an exe. Script runs on its own and creates excel file the problem is file is not created if i make it an exe

import pandas as pd
import numpy as np
import camelot
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
import requests
import urllib.request
import csv
from bs4 import BeautifulSoup
import os
import shutil
import glob
import math
import datetime
from datetime import datetime,timedelta

pg_main_data.to_excel('final_analysis.xlsx')
grouped_summary.to_excel('analysis_summary.xlsx')

Solution

  • As the pandas documentation specifies, in order for to_excel and read_excel methods to work you have to install one or more of the following packages alongside pandas:

    XLsxWriter  0.9.8  Excel writing
    openpyxl  2.5.7 Reading / writing for xlsx files
    pyxlsb   1.0.6  Reading for xlsb files
    xlrd   1.1.0   Excel reading
    xlwt   1.2.0   Excel writing
    

    Depending on your setup you might have not installed them or you might have not included them in pyinstaller list of packages.