首页 > 解决方案 > 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?

标签: pythonpyinstaller

解决方案


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]


推荐阅读