在windows下面运行 sklearn 中的代码,如果遇到 并行执行 n_jobs > 1 就会出现:
raise ImportError(‘[joblib] Attempting to do parallel computing ’
ImportError: [joblib] Attempting to do parallel computing without protecting your import on a system that does not support forking. To use parallel-computing in a script, you must protect your main loop using “if name == ‘main‘”. Please see the joblib documentation on Parallel for more information
这个错误
解决:
把所有的代码方到
if name == ‘main’
中就可以了