py2exe with multiprocessing fails to run the processes

可紊 提交于 2019-12-10 03:59:37

问题


I am using Python 2.6 over windows 7 and I am trying to use multiprocess:

p = Process(target=f, args=(SOME_ARGS))
p.start()
p.join()

while I run the code from CMD (using the interpreter) everything works fine, but after I create an exe file with py2exe, the execution of the process fails with the following error:

error: no such option: --multiprocessing-fork

all the solutions I found did not help. any ideas?


回答1:


You know you are using a app of year 2008? (py2exe), python is in constant actualizations, and then gives problems with py2exe, I can give you a better solution...

You can use cxfreeze: http://cx-freeze.sourceforge.net/

Simply, easy, good, and actualized.

I hope this helped you.




回答2:


You need a call to multiprocessing.freeze_support() when packaging a Python script into an executable for use on Windows. This call should come just after if __name__ == '__main__': before actually calling main()




回答3:


Here is a great link that explains how to freeze your multiprocessing program to make it work with py2exe:

Namely, you will need to call multiprocessing.freeze_support() right after your call to main:

import multiprocessing

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


来源:https://stackoverflow.com/questions/13514031/py2exe-with-multiprocessing-fails-to-run-the-processes

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