1

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

3 回答 3

3

正如文档指定pandas那样,为了使to_excel方法read_excel正常工作,您必须同时安装以下一个或多个软件包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

根据您的设置,您可能没有安装它们,或者您可能没有将它们包含在pyinstaller软件包列表中。

于 2020-10-15T08:46:23.917 回答
0

要从 excel 中读取和写入,您需要安装xlwt(以xls格式写入)、openpyxl(以xlsx格式写入)xlrd(以readexcel 格式写入)

使用以下命令安装所有这些依赖项:

pip install xlwt openpyxl xlrd
于 2020-10-15T08:52:43.907 回答
0

我使用 pandas read_excel 函数来读取 excel 文件。

你可以试试这个:

import pandas as pd

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

data.head()
于 2020-10-15T08:57:24.510 回答