Home > Back-end >  PyInstaller: Single-file executable doesn't work
PyInstaller: Single-file executable doesn't work

Time:06-10

PS C:\Users\user> pyinstaller onefile Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Scripts\pyinstaller.exe\__main__.py", line 7, in <module> File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\__main__.py", line 107, in run parser = generate_parser() ^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\__main__.py", line 78, in generate_parser import PyInstaller.building.build_main ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\building\build_main.py", line 35, in <module> from PyInstaller.depend import bindepend ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bindepend.py", line 26, in <module> from PyInstaller.depend import dylib, utils ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\utils.py", line 33, in <module> from PyInstaller.depend import bytecode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 95, in <module> _call_function_bytecode = bytecode_regex(rb""" ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 60, in bytecode_regex pattern = re.sub( ^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\re.py", line 190, in sub return _compile(pattern, flags).sub(repl, string, count) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 62, in <lambda> lambda m: _instruction_to_regex(m[1].decode()), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\PyInstaller\depend\bytecode.py", line 40, in _instruction_to_regex return re.escape(bytes([dis.opmap[x]])) ~~~~~~~~~^^^ KeyError: 'CALL_FUNCTION' I'm trying to create a single-file executable for Windows from a Python application, using pyinstaller, but the commend doesn't run and

CodePudding user response:

I think you made a mistake when you writing arguments can you give more details? or if you can't use PyInsaller on shell you can use this library with pyinstaller gui https://pypi.org/project/auto-py-to-exe/

CodePudding user response:

I honestly do not know what that error is. All I can say is that the command for making a single .exe file with pyinstaller is:

pyinstaller --onefile <filename>

For example pyinstaller --onefile myscript.py

I did a quick search and found this in pyinstaller: create one executable file

What you have done is pyinstaller onefile, which is the same as telling pyinstaller to create the executable using a file called onefile. When the program doesn't find the file 'onefile' it will not work, and it throws an error.

  • Related