need help to compile python with pyinstaller

前端 未结 2 369
-上瘾入骨i
-上瘾入骨i 2021-01-21 19:26

I want to distribute my python code on machines running windows 7+. It consists of a couple of .py files with the main in cprofiles_lmfit.py, together with a file <

相关标签:
2条回答
  • 2021-01-21 19:44

    A little too late but, incase someone stumbles here later on, you can use 'auto-py-to-exe' package to remove the hassle of using CMD. It provides a nice GUI with all the options of 'pyinstaller'.

    It can be installed using 'pip install auto-py-to-exe' and Can be used with 'auto-py-to-exe' at terminal.

    GitHub link : https://github.com/brentvollebregt/auto-py-to-exe

    0 讨论(0)
  • 2021-01-21 19:48

    I think I have a better solution for you: Use nsis in conjunction with pyinstaller.

    Here the answers in more detail:

    1. The file is that big because it contains the full python environment. I don't think there's much you can do about it, except creating a virtual environment that contains less files and using less packages in your code.
    2. Running the exe takes a long time because you have chosen the --onefile option. As a result it will unzip the exe, save it to a temporarary directory, and then run the script. When using --onefile it's actually not really an executable, but just a zip file that unzips and then starts itself. A better option might be:
    3. (and 4.). Instead of using the --onefile option, just package it normally with pyinstaller, and then create a script on top of it with nsis. That way the user can run the installer, which will have packaged all the files you put in the nsis script (including all the files created by pyinstaller) and also any additional files you would like. There will be a nice setup interface that will also create a shortcut to the .exe.
    0 讨论(0)
提交回复
热议问题