Search code examples
pythonpyinstaller

Getting "unrecognized arguments" error when trying to exclude modules in PyInstaller


I'm trying to run pyinstaller inside of a python program. Everything works except for when I try to use the --exclude-module PIL parameter, I get the following error: pyinstaller: error: unrecognized arguments: --exclude-module PIL

Here's my exact code:

import PyInstaller.__main__

PyInstaller.__main__.run([
    'res/output/output.py',
    '--onedir',
    '--exclude-module PIL',
    "--noconsole"
])

Solution

  • You need to split up the flags and its argument.

    For Example:

    PyInstaller.__main__.run([
        'res/output/output.py',
        '--onedir',
        '--exclude-module', 
        'PIL',
        '--noconsole'
    ])