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
549 views
in Technique[技术] by (71.8m points)

tkinter - How to convert a python project into an executable file with all additional scripts?

I know there have been a bunch of questions already asked regarding this but none of them really helped me. Let me explain the whole project scenario so that I provide a better clarity to my problem. The directory structure is somewhat like this shown below:

Project Directory Layout

enter image description here

I need to convert this whole GUI based project (The main file is using Tkinter module to create GUI) into main.exe which I can share with others while making sure that all the additional files work exactly the same way it is working now when I run this main.py via Command Prompt. When I use this command with pyinstaller -

"pyinstaller --onefile --noconsole main.py"

It creates main.exe which shows "Failed to execute script" on running. Please provide me a detailed explanation on what should I do to achieve what I have stated above. Thank you in advance.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

pyinstaller uses a few dirty tricks to compress a bunch of files into one

I recommend using cx_Freeze instead along with inno setup installer maker

do pip install cx_Freeze to install that and go here for inno setup

then copy the following into a file named setup.py in the same folder as your project

from cx_Freeze import setup, Executable

setup(name = "YOUR APP NAME" ,
      version = "1.0.0" ,
      description = "DESCRIPTION" ,
      executables = [Executable("PYTHON FILE", base = "Win32GUI")]
)

lastly run python setup.py build

if you want as onefile download this file here

just edit the file a bit and use inno compiler to make into installer


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

1.4m articles

1.4m replys

5 comments

57.0k users

...