Search code examples
python-3.xpyinstaller

Is pyinstaller's '--onefile' command working?


I had converted my python file using pyinstaller, using '--onefile' method. Hovewer, it still created folders.

Also, the .exe can run without these folders (I tried this by deleting other folders). So, is this exe file onefile?


Solution

  • Yes, the exe file that was created is a onefile. Let us look at the following command:

    pyinstaller --onefile myscript.py
    

    The pyinstaller documentation says the following:

    PyInstaller analyzes myscript.py and:

    • Writes myscript.spec in the same folder as the script.
    • Creates a folder build in the same folder as the script if it does not exist.
    • Writes some log files and working files in the build folder.
    • Creates a folder dist in the same folder as the script if it does not exist.
    • Writes the myscript executable folder in the dist folder.

    In the dist folder you find the bundled app you distribute to your users.

    The --onefile optional option creates a one-file bundled executable. The presence of the dist and build folders are a byproduct of the pyinstaller command.