Last night my apps were working fine, this morning I am getting this error:
Looks like to do with pandas and my excel file
ValueError: Excel file format cannot be determined, you must specify an engine manually.
2022-09-09 13:56:55,276: Error running WSGI application
2022-09-09 13:56:55,277: ValueError: Excel file format cannot be determined, you must specify an engine manually.
2022-09-09 13:56:55,277: File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2069, in
call
2022-09-09 13:56:55,277: return self.wsgi_app(environ, start_response)
I didn't change anything to my app since last night. I am getting the same error on another app that I haven't played with in a while too.
Did PythonAnywhere just install a new pandas version to all the servers or something maybe?
Any ideas what might have happened, Im not sure how to tackle this error :(
The error message looks like this:
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(
req.view_args)
File "/home/christofferrydestahl/mysite/webapp.py", line 63, in index
df = pd.read_excel(file_path)
File "/usr/local/lib/python3.10/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args,
kwargs)
File "/usr/local/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 364, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "/usr/local/lib/python3.10/site-packages/pandas/io/excel/_base.py", line 1195, in
init
raise ValueError(
ValueError: Excel file format cannot be determined, you must specify an engine manually.
In my code I've specified the like this:
Excel file format cannot be determined, you must specify an engine manually
so it looks like you need to tell Pandas which engine to use in order to load the Excel file. The docs provide a list of engines that can be used. You should also check that the file that you're trying to load is actually an Excel file.
I thought I already did specify the engine here:
df = pd.read_excel(file_path, engine='openpyxl')
The file is an .xlsx-file.
The strange thing is that the app is working locally.
# Read the Excel-filentry:df=pd.read_excel(uploaded_file_path,engine='openpyxl')names=df['Name'].tolist()results=[]except:print("Error reading the god damn Excel file")
I've tried to delete the .cache directory but it still gives me the same error even though I reloaded the app.
Sorry, there was a path issue. But now I get this error that I've been trying to solve but keeps getting stuck.
In the error logs:
"zipfile.BadZipFile: File is not a zip file"
But I'm uploading a .xlsx file.
In the browser I get another message:
Error: Uploaded file is corrupted or not a valid Excel file.
Sorry, we have had to rate-limit your feedback sending. Please try again in a few moments...
Thanks for the feedback! Our tireless devs will get back to you soon.