Python multiprocessing throws error with argparse and pyinstaller

ε祈祈猫儿з 提交于 2019-12-04 18:06:26

(A bit late but it can be useful for someone else in the future...)

I had the same problem, after some research I found this multiprocessing pyInstaller recipe that states:

When using the multiprocessing module, you must call

multiprocessing.freeze_support()

straight after the if __name__ == '__main__': line of the main module.

Please read the Python library manual about multiprocessing.freeze_support for more information.

Adding that line of code solved the problem for me.

I may be explaining the obvious, but you don't give us much information to work with.

python complete_script.py --arg1=xy --arg2=yz

This sort of call tells me that your parser is setup to accept at least these 2 arguments, ones flagged with '--arg1' and '--arg2'.

The error tells me that this parser (or maybe some other) is also seeing this string:

--multiprocessing-fork 1448

Possibly generated by the multiprocessing code. It would be good to see the usage part of the error, just to confirm which parser is complaining.

One of my first open source contributions to Python was to enhance the warnings about multiprocessing on Windows.

https://docs.python.org/2/library/multiprocessing.html#windows

Is your parser protected by a if __name__ block? Should this particular parser be called when run in a fork? You probably designed the parser to work when the program is called as a standalone script. But when happens when it is imported?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!