adolfsingh
adolfsingh

Reputation: 55

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')

Upvotes: 1

Views: 2849

Answers (4)

xlmaster
xlmaster

Reputation: 721

As I guess right, this problem has not been resolved. I have the same issue. File updates(xlsm) but in Temp/MEIPASS folder, does not bring it to bundled folder

Upvotes: 0

Ayse
Ayse

Reputation: 632

I use the pandas read_excel function to read the excel file.

You can try this:

import pandas as pd

data = pd.read_excel('Yourdata.xlsx', sheet_name='Sheetname')

data.head()

Upvotes: 0

Tasnuva Leeya
Tasnuva Leeya

Reputation: 2795

to read and write from excel you need to install xlwt (to write in xls format), openpyxl(to write in xlsx format) xlrd (to read excel)

install all these dependencies using:

pip install xlwt openpyxl xlrd

Upvotes: 0

sophros
sophros

Reputation: 16660

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.

Upvotes: 3

Related Questions