我无法获得pyinstaller将任何内容转换为.exe

I can not get pyinstaller to convert anything to .exe

提问人:air_strike 提问时间:4/22/2023 最后编辑:Kostas Nitafair_strike 更新时间:4/23/2023 访问量:225

问:

我正在尝试使用 pyinstaller 为我的任何 python 文件制作一个 .exe 文件,但它总是显示相同的错误。

在尝试了带有导入等的软件包之后,我决定用我能想到的最简单的东西来测试它:

user_input = int(input())
if user_input == 1:
    print('Hello world')
else:
    print('Bye, bye')

但即便如此,它也会给我带来与其他时间相同的错误:

312 INFO: PyInstaller: 5.10.1
312 INFO: Python: 3.9.7
343 INFO: Platform: Windows-10-10.0.19045-SP0
359 INFO: wrote D:\Python\OOP\test.spec
359 INFO: UPX is not available.
359 INFO: Extending PYTHONPATH with paths
['D:\\Python\\OOP']
Traceback (most recent call last):
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call
    return isolated.call(function, *args, **kwargs)
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 293, in call
    ok, output = loads(b64decode(self._read_handle.readline()))
EOFError: EOF read where object expected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Python\OOP\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\__main__.py", line 194, in _console_script_run
    run()
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\__main__.py", line 180, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\__main__.py", line 61, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\building\build_main.py", line 978, in main
    build(specfile, distpath, workpath, clean_build)
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\building\build_main.py", line 900, in build
    exec(code, spec_namespace)
  File "D:\Python\OOP\test.spec", line 7, in <module>
    a = Analysis(
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\building\build_main.py", line 381, in __init__
    self.hookspath += discover_hook_directories()
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 403, in wrapped
    return call(function, *args, **kwargs)
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call
    return isolated.call(function, *args, **kwargs)
  File "d:\python\oop\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 247, in __exit__
    self._write_handle.flush()
OSError: [Errno 22] Invalid argument

我第一次运行pyinstaller时,我收到以下错误消息:

如果这很重要,我正在使用 Pycharm 作为 IDE。

提前感谢您抽出宝贵时间接受采访!

python-3.x pyinstaller 无效参数 eoferror

评论

1赞 Alexander 4/22/2023
您需要完全卸载 pyinstaller,然后创建一个虚拟环境并在虚拟环境中重新安装...如果它仍然不起作用,那么您需要重新安装 Python。

答:

1赞 air_strike 4/23/2023 #1

为文件夹创建一个虚拟环境解决了这个问题。非常感谢亚历山大

评论

1赞 Ben the Coder 4/25/2023
您的答案可以通过其他支持信息进行改进。请编辑以添加更多详细信息,例如引文或文档,以便其他人可以确认您的答案是正确的。您可以在帮助中心找到有关如何写出好答案的更多信息。