import PyInstaller.__main__ PyInstaller.__main__.run([ 'my_script.py', '--onefile', '--windowed' ]) #Is equivalent to: pyinstaller my_script.py --onefile --windowed