inputs icon indicating copy to clipboard operation
inputs copied to clipboard

freeze_support ERROR (keyboard)

Open SmartySmart702 opened this issue 7 years ago • 5 comments

I have this error when I use the keyboard key print example script. If I work with the Gamepad listener everything works fine! I'm new to programing so I dont' know what this means.

Win 10 x64

`An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.`

SmartySmart702 avatar Aug 26 '18 23:08 SmartySmart702

Interesting, I have never seen that before. I will have a look.

zeth avatar Aug 28 '18 15:08 zeth

Here is the whole Console Log. Maybe it helps you.

C:\Users\WS-001\Desktop\Programming\Python\Robot>python InputTest.py Traceback (most recent call last): File "", line 1, in File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 114, in _main prepare(preparation_data) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 225, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path run_name="mp_main") File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\WS-001\Desktop\Programming\Python\Robot\InputTest.py", line 4, in events = get_key() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2940, in get_key return keyboard.read() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2313, in read return next(iter(self)) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2273, in iter event = self._do_iter() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2292, in _do_iter data = self._get_data(read_size) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2365, in _get_data return self._pipe.recv_bytes() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2330, in _pipe self._listener.start() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 112, in start self._popen = self._Popen(self) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\popen_spawn_win32.py", line 33, in init prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 143, in get_preparation_data _check_not_importing_main() File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main is not going to be frozen to produce an executable.''') RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

Exception ignored in: <function InputDevice.del at 0x000002749C1BCC80> Traceback (most recent call last): File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\site-packages\inputs.py", line 2337, in del File "C:\Users\WS-001\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 124, in terminate AttributeError: 'NoneType' object has no attribute 'terminate'

And here is the Code I'm trying to run (the spaces are correct but not here, don't know why).

import inputs from inputs import get_key while 1: events = get_key() for event in events: print(event.ev_type, event.code, event.state)

SmartySmart702 avatar Aug 28 '18 18:08 SmartySmart702

Anything new about this issue? I really like your library and it would be useful if I don't need an extra library for keyboard input :D

SmartySmart702 avatar Sep 14 '18 22:09 SmartySmart702

I met the same issue

cwlinghk avatar Nov 18 '19 06:11 cwlinghk

This is expected on Windows. Just put it under

if __name__ == "__main__":
    while 1:
        events = get_key()
        if events:
            for event in events:
                print(event.ev_type, event.code, event.state)

singhjayant92 avatar May 20 '20 12:05 singhjayant92