成功解决ImportError: [joblib] Attempting to do parallel computing without protecting your import on a sy

简介: 成功解决ImportError: [joblib] Attempting to do parallel computing without protecting your import on a sy

解决问题


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







解决思路


导入错误:[joblib]试图在不支持分叉的系统上执行并行计算而不保护导入。要在脚本中使用并行计算,您必须使用"if __name__ == '__main__'"来保护主循环。有关详细信息,请参阅并行的joblib文档。


tips:

1、凡是有调用方法的时候,均会出现该错误!

from sklearn.grid_search import GridSearchCV

因为sklearn.grid_search方法已经有所重构!







解决方法


在主程序最顶部加入主代码即可!


if __name__=='__main__':   #主程序最顶端,加入此行代码即可

哈哈,大功告成!


 


相关文章
|
8月前
|
编解码 算法 Python
ImportError: cannot import name ‘_update_worker_pids’ from ‘torch._C’
ImportError: cannot import name ‘_update_worker_pids’ from ‘torch._C’
96 0
|
6月前
|
Ubuntu Linux Python
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
266 2
|
8月前
|
PyTorch 算法框架/工具
The “freeze_support()“ line can be omitted if the program is not going to be frozen
The “freeze_support()“ line can be omitted if the program is not going to be frozen
136 1
|
虚拟化
成功解决Failed to execute stage ‘Setup validation’: Hardware does not support virtualization.
成功解决Failed to execute stage ‘Setup validation’: Hardware does not support virtualization.
|
Java Android开发
Java Heap Space: Understanding and Resolving Memory Issues
Java Heap Space: Understanding and Resolving Memory Issues
成功解决Failed to execute stage ‘Setup validation’: Cannot locate gluster packages
成功解决Failed to execute stage ‘Setup validation’: Cannot locate gluster packages
|
并行计算
Hint: This means that multiple copies of the OpenMP runtime have been linked into the program.
Hint: This means that multiple copies of the OpenMP runtime have been linked into the program.
297 0
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
|
算法 Java BI
【论文阅读】(2013)A goal-driven approach to the 2D bin packing and variable-sized bin packing problems
【论文阅读】(2013)A goal-driven approach to the 2D bin packing and variable-sized bin packing problems
176 0
【论文阅读】(2013)A goal-driven approach to the 2D bin packing and variable-sized bin packing problems
E: Unable to correct problems, you have held broken packages.
在使用服务器配置环境中遇到的问题,先将解决方案列下: