简体   繁体   English

PyInstaller:单文件可执行文件不起作用

[英]PyInstaller: Single-file executable doesn't work

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' 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 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'我正在尝试创建一个- 来自 Python 应用程序的 Windows 的可执行文件,使用 pyinstaller,但命令不运行并且

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 创建单个 .exe 文件的命令是:

pyinstaller --onefile <filename>

For example pyinstaller --onefile myscript.py例如pyinstaller --onefile myscript.py

I did a quick search and found this in pyinstaller: create one executable file我快速搜索并在pyinstaller 中找到了这个:创建一个可执行文件

What you have done is pyinstaller onefile , which is the same as telling pyinstaller to create the executable using a file called onefile.您所做的是pyinstaller onefile ,这与告诉 pyinstaller 使用名为 onefile 的文件创建可执行文件相同。 When the program doesn't find the file 'onefile' it will not work, and it throws an error.当程序找不到文件“onefile”时,它将无法工作,并引发错误。

This was addressed here: https://github.com/pyinstaller/pyinstaller/issues/6950这是在这里解决的: https://github.com/pyinstaller/pyinstaller/issues/6950

Looks like it's been merged in so make sure your PyInsaller version is 5.6 or greater.看起来它已被合并,因此请确保您的 PyInsaller 版本为 5.6 或更高版本。

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/或者如果你不能在 shell 上使用 PyInsaller,你可以使用这个库和 pyinstaller gui https://pypi.org/project/auto-py-to-exe/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM