Python Pyinstaller ERRNO 22 Invalid Argument

Viewed 3388

I am trying to use pyinstaller to make my python code more user-friendly, and until yesterday, it was working. When I ran it today I got the error below:

C:\Users\user\Desktop\PythonProjects38>pyinstaller --onefile TransmittalEXE.py
83 INFO: PyInstaller: 4.0
83 INFO: Python: 3.8.5
83 INFO: Platform: Windows-10-10.0.18362-SP0
84 INFO: wrote C:\Users\user\Desktop\PythonProjects38\TransmittalEXE.spec
...
31623 INFO: checking PKG
31623 INFO: Building PKG because PKG-00.toc is non existent
31628 INFO: Building PKG (CArchive) PKG-00.pkg
41852 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
41915 INFO: Bootloader c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
41915 INFO: checking EXE
41917 INFO: Building EXE because EXE-00.toc is non existent
41921 INFO: Building EXE from EXE-00.toc
41927 INFO: Updating manifest in C:\Users\user\Desktop\PythonProjects38\build\TransmittalEXE\run.exe.d66z9a0v
42037 INFO: Updating resource type 24 name 1 language 0
42050 INFO: Appending archive to EXE C:\Users\user\Desktop\PythonProjects38\dist\TransmittalEXE.exe
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\user\Desktop\PythonProjects38\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
    exec(code, spec_namespace)
  File "C:\Users\user\Desktop\PythonProjects38\TransmittalEXE.spec", line 20, in <module>
    exe = EXE(pyz,
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\building\api.py", line 446, in __init__
    self.__postinit__()
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "c:\users\user\desktop\pythonprojects38\venv\lib\site-packages\PyInstaller\building\api.py", line 622, in assemble
    with open(exe, 'rb') as infh:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\user\\Desktop\\PythonProjects38\\build\\TransmittalEXE\\run.exe.d66z9a0v'

For more reference I've tried uninstalling and reinstalling pyinstaller and pywin32 to no avail. My command prompt entry is pyinstaller --onefile TransmittalEXE.py.

Has anyone else encountered this issue? I've seen similar on this forum, but not this exact issue.

2 Answers

I had the same problem and I was able to fix it by going to Windows anti-virus protection option and adding the folder my script was as an exception.

Go to Start > Settings > Update & Security >Windows Security , and then select Virus & threat protection. Under Virus & threat protection settings, select Manage settings. Add the folder with your desired script as an exception.

Without the knowing of the script you are changing to exe, it is difficult to guess. The attached slice from the command line in your question about the error also says nothing, as @Eric Sunrightly pointed out. So it remains to give the reason for the error in other cases seemingly not necessarily related to your question, hoping that through the associations it will be possible to remove the cause of the error in yours and maybe in other cases. Eventually, I found this question looking for an answer to the same error. For me, the reason for the error was to provide the optional argument –icon=app.ico. It turned out that a file with the extension .ico was not an icon at all, but a different format, changed by the changing only the extension. When I changed a file saved in the format . png to .ico in the correct way pyinstaller stopped reporting an error.

Related