我的并行脚本工作了一段时间。我使用了multiprocessing
库和函数starmap
。但是现在当我尝试运行它时,会显示以下AttributeError
:
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018,
16:13:55) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.3.1 -- An enhanced Interactive Python.
Traceback (most recent call last):
File "<ipython-input-1-d3a2b861c70a>", line 1, in <module>
runfile('E:/Python/E2Oeval.py', wdir='E:/Python')
File "C:\Users\AppData\Local\conda\conda\envs\py36\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\AppData\Local\conda\conda\envs\py36\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "E:/Python/E2Oeval.py", line 1227, in <module>
df_Qobs_percs, df_Qsim_percs, df_sdQsim_percs, df_KGE_alpha, df_KGE_beta, df_KGE_r = ee.main_par(db_Qobs_meta_dir, Ens_mean_dir, Ens_sd_dir, db_Qobs_dir)
File "E:/Python/E2Oeval.py", line 835, in main_par
res = p.starmap(self.main, subsets)
File "C:\Users\AppData\Local\conda\conda\envs\py36\lib\multiprocessing\pool.py", line 274, in starmap
return self._map_async(func, iterable, starmapstar, chunksize).get()
File "C:\Users\AppData\Local\conda\conda\envs\py36\lib\multiprocessing\pool.py", line 644, in get
raise self._value
AttributeError: 'NoneType' object has no attribute 'write'
错误仅发生在Windows上,因为unix代码正在运行。我需要在Windows机器上运行它,因为它需要一些笔记本电脑不能提供的CPU电源。有谁知道如何检测导致错误的NoneType
对象?