multiprocessing_on_dill结果导致ModuleNotFoundError“ __builtin__”

时间:2019-04-30 22:09:14

标签: python python-multiprocessing dill

为克服泡菜的局限性,我改用multiprocessing_on_dill

这开始产生错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 107, in spawn_main
    exitcode = _main(fd)
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 117, in _main
    self = reduction.pickle.load(from_parent)
ModuleNotFoundError: No module named '__builtin__'

有办法克服吗?

令人惊讶的是,它仍然引用C:\ProgramData\Anaconda3\lib\multiprocessing\
multiprocessing_on_dill有自己的文件夹C:\ProgramData\Anaconda3\Lib\site-packages\multiprocessing_on_dill,具有相同的文件集。

1 个答案:

答案 0 :(得分:0)

我建议您使用multiprocess而不是multiprocessing_on_dill ... dill作者(我)会更好地支持和维护前者。似乎multiprocess_on_dill正在寻找__builtin__,这是内置函数驻留在python 2中的地方...在python 3中,它们位于builtins

>$ python
Python 2.7.16 (default, Apr  1 2019, 14:50:56) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
>>> 

>$ python
Python 3.6.8 (default, Dec 30 2018, 13:04:41) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '__builtin__'
>>> import builtins
>>>

所以,我认为是您正在运行python 3,并使用python 2版本的代码-或该模块不完全支持python 3。