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

Python Creating an installable program using pyinstaller

I am trying to use pyinstaller to create an installer for my python program, which is typically run as follows:

python -m <folder_name>

( I can't run by calling __main.__py) Inside <folder_name> I have __main__.py, an empty __init__.py, and various folders containing python code.

I don't see any options in the pyinstaller documentation to support this type of program structure. Are there options for this?

question from:https://stackoverflow.com/questions/65945386/python-creating-an-installable-program-using-pyinstaller

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

1 Reply

0 votes
by (71.8m points)

A way to tackle this could be to create another python file which is something like this

from <folder_name>.main import main
if __name__ == '__main__':
    main()

And then use pyinstaller on this file.

Also, make sure that you have an __init__.py in all the folders with python files so that they are treated like packages when performing a relative import.

Reference posts [1] [2]


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

...