多线程运算出现error
ipyparallel.error.RemoteError(‘NameError’, “name ‘np’ is not defined”),
原因有二:
1)numpy的导入,只会导入本地engine,要保证所有的engine中都导入numpy.
解决办法:
with dview.sync_imports():
import numpy
2)the usual renaming of the import handle in the same line like in import matplotlib.pyplot as plt does not work on the remote engine, the as plt is ignored remotely, while it executes locally
解决办法:
# import numpy here and everywhere
with rc[