在我的项目中,我使用argprse传递参数,而在脚本中的某个地方使用多重处理来完成其余的计算。如果我从命令提示符处调用脚本,则脚本工作正常。
“ python complete_script.py --arg1=xy --arg2=yz”。
但是在使用Pyinstaller使用命令“ pyinstaller --onefile complete_script.py”将其转换为exe后,它将抛出
错误
“错误:无法识别的参数:--multiprocessing-fork 1448”
任何建议,我如何使这项工作。或任何其他选择。我的目标是创建一个exe应用程序,可以在未安装Python的其他系统中调用该应用程序。
以下是我的工作站的详细信息:
Platform: Windows 10
Python : 2.7.13 <installed using Anaconda>
multiprocessing : 0.70a1
argparse: 1.1
Run Code Online (Sandbox Code Playgroud)
从评论中复制:
def main():
main_parser = argparse.ArgumentParser()
< added up arguments here>
all_inputs = main_parser.parse_args()
wrap_function(all_inputs)
def wrap_function(all_inputs):
<Some calculation here >
distribute_function(<input array for multiprocessing>)
def distribute_function(<input array>):
pool = Pool(process = cpu_count)
jobs = [pool.apply_async(target_functions, args = (i,) for i in input_array)]
pool.close()
Run Code Online (Sandbox Code Playgroud) python pyinstaller python-2.7 argparse python-multiprocessing