Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freeze_support ValueError: not enough values to unpack (expected 2, got 1) #7482

Closed
pitzmoni opened this issue Mar 9, 2023 · 7 comments
Closed
Labels
triage Please triage and relabel this issue

Comments

@pitzmoni
Copy link

pitzmoni commented Mar 9, 2023

Hi!

I was using auto-py-to-exe and calling one function (lda model) causes the main window reopening multiple times.

So I tried to use freeze_support via documentation:

from multiprocessing import Process, freeze_support

def main():
    ...
    app.mainloop()

if __name__ == '__main__':
    freeze_support()
    Process(target=main).start()

and got following error:

File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)

Any help greatly appreciated!

@pitzmoni pitzmoni added the triage Please triage and relabel this issue label Mar 9, 2023
@rokm
Copy link
Member

rokm commented Mar 9, 2023

Can you try modifying your code as follows:

import sys
print("New process:", sys.argv)

from multiprocessing import Process, freeze_support

def main():
    ...
    app.mainloop()

if __name__ == '__main__':
    freeze_support()
    Process(target=main).start()

and paste the full output of the program, so we can see how the processes are called and what are the arguments in the (sub)process that fails.

Also, what version of python are you using?

@pitzmoni
Copy link
Author

pitzmoni commented Mar 10, 2023

Hi, thanks for the prompt reply.

Python version is 3.10.5

Full output:

I:\MONI\Codes\event-evaluation-app\output\szentiment_elemző>szentiment_elemző.exe
New process: ['szentiment_elemző.exe']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', 'parent_pid=3284', 'pipe_handle=312']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Process Process-1:
Traceback (most recent call last):
  File "multiprocessing\process.py", line 315, in _bootstrap
  File "multiprocessing\process.py", line 108, in run
  File "App.py", line 506, in main
  File "pandas\util\_decorators.py", line 211, in wrapper
  File "pandas\util\_decorators.py", line 317, in wrapper
  File "pandas\io\parsers\readers.py", line 950, in read_csv
  File "pandas\io\parsers\readers.py", line 605, in _read
  File "pandas\io\parsers\readers.py", line 1442, in __init__
  File "pandas\io\parsers\readers.py", line 1729, in _make_engine
  File "pandas\io\common.py", line 857, in get_handle
FileNotFoundError: [Errno 2] No such file or directory: 'I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\files/positive_list.txt'

I:\MONI\Codes\event-evaluation-app\output\szentiment_elemző>szentiment_elemző.exe
New process: ['szentiment_elemző.exe']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', 'parent_pid=6492', 'pipe_handle=324']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\core_widget_classes\ctk_base_class.py:179: UserWarning: CTkButton Warning: Given image is not CTkImage but <class 'tkinter.PhotoImage'>. Image can not be scaled on HighDPI displays, use CTkImage instead.

  warnings.warn(f"{type(self).__name__} Warning: Given image is not CTkImage but {type(image)}. Image can not be scaled on HighDPI displays, use CTkImage instead.\n")
pandas\core\generic.py:4214: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
pandas\util\_decorators.py:312: FutureWarning: In a future version of pandas all arguments of DataFrame.drop except for the argument 'labels' will be keyword-only.
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '-B', '-S', '-E', '-s', '-c', 'from joblib.externals.loky.backend.resource_tracker import main; main(6408, False)']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '5544']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '5832']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '5916']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6788']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '4768']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6448']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6456']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6404']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6728']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6732']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6492']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6388']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '4996']
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)
[7800] Failed to execute script 'App' due to unhandled exception!
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6216']
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)
[5660] Failed to execute script 'App' due to unhandled exception!
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)
[1952] Failed to execute script 'App' due to unhandled exception!
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '4828']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6900']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6868']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6196']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '5456']
New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', '6244']
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)
[11200] Failed to execute script 'App' due to unhandled exception!
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
ValueError: not enough values to unpack (expected 2, got 1)
[13244] Failed to execute script 'App' due to unhandled exception!
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
Traceback (most recent call last):
  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
Traceback (most recent call last):
ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "App.py", line 608, in <module>
[  File "App.py", line 608, in <module>
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
7764] ValueError: not enough values to unpack (expected 2, got 1)
  File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_multiprocessing.py", line 46, in _freeze_support
Failed to execute script 'App' due to unhandled exception!
[ValueError: not enough values to unpack (expected 2, got 1)
13472] [Failed to execute script 'App' d1ue to unhandled exception!
Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1921, in __call__
  File "customtkinter\windows\widgets\ctk_button.py", line 553, in _clicked
    self._command()
  File "App.py", line 227, in topik_elemzes
  File "pyLDAvis\gensim_models.py", line 123, in prepare
  File "pyLDAvis\_prepare.py", line 439, in prepare
  File "pyLDAvis\_prepare.py", line 276, in _topic_info
  File "joblib\parallel.py", line 1098, in __call__
  File "joblib\parallel.py", line 975, in retrieve
  File "joblib\_parallel_backends.py", line 567, in wrap_future_result
  File "concurrent\futures\_base.py", line 446, in result
  File "concurrent\futures\_base.py", line 391, in __get_result
joblib.externals.loky.process_executor.TerminatedWorkerError: A worker process managed by the executor was unexpectedly terminated. This could be caused by a segmentation fault while calling the function or by an excessive memory usage causing the Operating System to kill the worker.

New process: ['I:\\MONI\\Codes\\event-evaluation-app\\output\\szentiment_elemző\\szentiment_elemző.exe', '--multiprocessing-fork', 'parent_pid=7976', 'pipe_handle=2248']
PyInstaller\loader\pyimod02_importers.py:352: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\appearance_mode\appearance_mode_tracker.py:9: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if Version(darkdetect.__version__) < Version("0.3.1"):
customtkinter\windows\widgets\core_widget_classes\ctk_base_class.py:179: UserWarning: CTkButton Warning: Given image is not CTkImage but <class 'tkinter.PhotoImage'>. Image can not be scaled on HighDPI displays, use CTkImage instead.

  warnings.warn(f"{type(self).__name__} Warning: Given image is not CTkImage but {type(image)}. Image can not be scaled on HighDPI displays, use CTkImage instead.\n")

@bwoodsend
Copy link
Member

New process: ['I:\MONI\Codes\event-evaluation-app\output\szentiment_elemző\szentiment_elemző.exe', '-B', '-S', '-E', '-s', '-c', 'from joblib.externals.loky.backend.resource_tracker import main; main(6408, False)']

I'm guessing this is the issue. You have unsupportable loky in there too.

@pitzmoni
Copy link
Author

Thanks, that helped.

I added to my code:

from joblib import parallel_backend

parallel_backend("threading")

Works fine now :)

@bwoodsend
Copy link
Member

@rokm How would you feel about putting #7482 (comment) into a runtime hook?

@rokm
Copy link
Member

rokm commented Mar 10, 2023

@rokm How would you feel about putting #7482 (comment) into a runtime hook?

I'd really rather not be switching joblib backends behind users' backs, even if we do not support the default loky backend.

@bwoodsend
Copy link
Member

In that case, I guess we just banish this as a duplicate (albeit a particularly unclear one) of #7008.

@bwoodsend bwoodsend closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage Please triage and relabel this issue
Projects
None yet
Development

No branches or pull requests

3 participants