我正在使用Python 3.6,並試圖遵循下面的網站(完整代碼也在下面)的第一個例子,以下錯誤: https://docs.python.org/3.6/library/multiprocessing.htmlPython多處理錯誤:AttributeError:模塊'__main__'沒有屬性'__spec__'
錯誤消息: AttributeError: module '__main__' has no attribute '__spec__'
完整的示例代碼:
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
我想谷歌搜索,並在搜索堆棧Overflo但我只發現了另一個這種錯誤的情況,它沒有答案。
張貼的代碼工作正常,我的機器 – bendl
我使用蟒蛇/ Spyder的與Python 3.6 ...也許有什麼關係呢? – user8474060
我在Spyder 3.1.4上使用Spyder 3.1.2和Python 3.6.0(Anaconda 4.3.1)在Windows 7中 – bendl