Python Forum
Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691
#1
Hi everyone,

I am trying to make the executable of my python script with Pyinstaller. I am using:
PyInstaller: 3.6
Python: 3.7.7
Windows 10 64Bits

When I run my script from Windows command terminal, it works fine. When I run the exe produced by Pyinstaller I have this error shown on terminal:

Output:
Process SpawnProcess-4: Traceback (most recent call last): File "multiprocessing\process.py", line 297, in _bootstrap File "multiprocessing\process.py", line 99, in run File "concurrent\futures\process.py", line 233, in _process_worker File "multiprocessing\queues.py", line 113, in get File "multiprocessing\managers.py", line 943, in RebuildProxy File "multiprocessing\managers.py", line 793, in __init__ File "multiprocessing\managers.py", line 847, in _incref File "multiprocessing\connection.py", line 490, in Client File "multiprocessing\connection.py", line 691, in PipeClient FileNotFoundError: [WinError 2] The system cannot find the file specified A process in the process pool was terminated abruptly while the future was running or pending. --> Error multiprocessor]
This is my piece of code which create this error:


 with concurrent.futures.ProcessPoolExecutor() as executor:
            try:
                #multiprocesses = executor.map(mymodules.run_smartphone, list_arguments_smartphones)
                multiprocesses = executor.map(mymodules.run_smartphone, list_smartphones_connected,
                                              [lock] * len(list_smartphones_connected))
                for function_return_value in multiprocesses:
                    print(function_return_value)

            except Exception as ex:
                print(f"{ex} --> Error multiprocesses")
My code start with the freeze as recommended:
if __name__ == '__main__':
   import multiprocessing
   multiprocessing.freeze_support()
So I made the exe with the option --dir in order to make the executable with dolls, and I get exact same issue.

I run some specific Pyinstaller commands, it is displaying something, but I don't understand what it means:

Output:
E:\>pyi-bindepend Myprogram.exe Myprogram.exe {'KERNEL32.dll', '*_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_none', 'WS2_32.dll', 'ADVAPI32.dll'} E:\>pyi-archive_viewer Myprogram.exe pos, length, uncompressed, iscompressed, type, name [(0, 270, 354, 1, 'm', 'struct'), (270, 1124, 1832, 1, 'm', 'pyimod01_os_path'), (1394, 4376, 9337, 1, 'm', 'pyimod02_archive'), (5770, 7417, 18651, 1, 'm', 'pyimod03_importers'), (13187, 1868, 4175, 1, 's', 'pyiboot01_bootstrap'), (15055, 266, 321, 1, 's', 'pyi_rth_certifi'), (15321, 1080, 1775, 1, 's', 'pyi_rth_multiprocessing'), (16401, 8845, 18589, 1, 's', 'Myprogram'), (25246, 3052666, 3052666, 0, 'z', 'PYZ-00.pyz')] ?
so I added in the .spec file some hiddenimport:

hiddenimports=["socks","multiprocessing","concurrent"],
as I saw issues with multiprocessing and futures.. But it didn't fix anything

I tried this one:

hiddenimports=["socks","multiprocessing","concurrent.futures"],
still same issue.

So I check this line 691 in this connection.py file, but I don't understand the issue:

def PipeClient(address):
        '''
        Return a connection object connected to the pipe given by `address`
        '''
        t = _init_timeout()
        while 1:
            try:
                _winapi.WaitNamedPipe(address, 1000)<==------------------------[line 691]
                h = _winapi.CreateFile(
                    address, _winapi.GENERIC_READ | _winapi.GENERIC_WRITE,
                    0, _winapi.NULL, _winapi.OPEN_EXISTING,
                    _winapi.FILE_FLAG_OVERLAPPED, _winapi.NULL
                    )
            except OSError as e:
                if e.winerror not in (_winapi.ERROR_SEM_TIMEOUT,
                                      _winapi.ERROR_PIPE_BUSY) or _check_timeout(t):
                    raise
            else:
                break
        else:
            raise

        _winapi.SetNamedPipeHandleState(
            h, _winapi.PIPE_READMODE_MESSAGE, None, None
            )
        return PipeConnection(h)
I am not good enough in Python to fix this issue. I can just make the conclusion that Pyinstaller is breaking something as the script is running perfectly fine from the terminal. Also I see that system is saying it cannot find a file. So a file or module is missing, that is why I tried some stuff in .spec file.

Does anyone know the source of my problem please?
Reply
#2
Hi Formationgrowthhacking
I'm afraid I can't be much help to you,
have you seen this post:
https://stackoverflow.com/questions/1590...rocesspool

It suggests that if you haven't used:
if __name__ == '__main__':
    main()
it might cause the error you are seeing.

If this doesn't help all I can do
is offer to try and use Pyinstaller
on your code from my machine to see if it
works or gets the same error.

good luck
steve
Reply
#3
The error is it cannot find a file. If it works in terminal, but the exe fails, most probably you have problem with paths
look at https://pyinstaller.readthedocs.io/en/st...nformation
There is nice script that can help you identify which path you should use when converted to executable. from information provided it's difficult to identify exactly where the issue with the path is.

Although you may have hidden imports, I think they would produce a different kind of error - some sort of import error if it cannot find a module.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create Choices from .ods file columns cspower 3 575 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  Recommended way to read/create PDF file? Winfried 3 2,855 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  Use PM4PY and create working file thomaskissas33 0 632 Nov-14-2023, 06:53 AM
Last Post: thomaskissas33
  Create csv file with 4 columns for process mining thomaskissas33 3 738 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  Input network device connection info from data file edroche3rd 6 988 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,263 Jun-27-2023, 01:17 PM
Last Post: diver999
  create exe file for linux? korenron 2 957 Mar-22-2023, 01:42 PM
Last Post: korenron
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,507 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Getting last line of each line occurrence in a file tester_V 1 856 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  Create Excel Line Chart Programmatically dee 3 1,178 Dec-30-2022, 08:44 PM
Last Post: dee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020