Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

Error with openpyxl and pyinstaller with --onefile

I have basic knowledge of python and using coding rarely

I have a problem with a specific situation when I want to convert my python code to an ".exe" file using pyinstaller. My code has openpyxl library and when I tried to convert it to .exe file, I can't do it. I simplified the problem and shared an example different code that I have the same problem with.

I did some trials looking at some suggestions on the internet, and my final status is I can create an exe file writing "pyinstaller test.py" and it works great. But as you know it creates a mess of hundreds of files, but I want to give the program to my professor. So I want to have a just ".exe" file. So I used on command prompt "pyinstaller --onefile test.py". But it does NOT work. I am grateful for your help in advance.

from openpyxl import Workbook

a = int(input("a: "))
b = int(input("b: "))

wb = Workbook()
ws = wb["Sheet"]

ws.cell(1,1).value = a+b

with open("deneme.txt","w") as f:
    f.write("{} + {} = {}".format(a, b, a+b))

wb.save(filename="deneme.xlsx")
question from:https://stackoverflow.com/questions/65878278/error-with-openpyxl-and-pyinstaller-with-onefile

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am super dumb and an idiot such that I have not waited for 2 minutes more in the black window and I have spent my 2 hours to find a solution.

I was thinking that pyinstaller finished its process and I was closing the black window. There is only a longer process when you want to do --onefile.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...