在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’
中就可以了