python-3.xpyinstallerinvalid-argumenteoferror

I can not get pyinstaller to convert anything to .exe


I am trying to use pyinstaller to make an .exe file of any of my python files, but it always shows the same errors.

After trying with a package with imports an so on, I decided to test it with the simplest thing I can think of:

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

But even with that it gives me the same Errors as every other time:

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

The first time I ran pyinstaller I got this error message:

I am using Pycharm as IDE, if that matters.

Thank you in advance for your time!


Solution

  • Creating a virtual environment for the folder solved it. Many thanks to Alexander !