This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: AttributeError when running multiprocessing on MacOS 11 with Apple Silicon (M1)
Type: Stage: resolved
Components: macOS Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, reeyarn, ronaldoussoren
Priority: normal Keywords:

Created on 2020-12-22 02:00 by reeyarn, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg383565 - (view) Author: Reeyarn Li (reeyarn) Date: 2020-12-22 02:00
I just run the sample code from multiprocessing's documentation page:


from multiprocessing import Pool

def f(x):
    return x*x

with Pool(5) as p:
    print(, [1, 2, 3]))

## end of code

And it cannot run, with the following error messages:
Process SpawnPoolWorker-2:
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/", line 315, in _bootstrap
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/", line 114, in worker
    task = get()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/multiprocessing/", line 358, in get
    return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
msg383567 - (view) Author: Reeyarn Li (reeyarn) Date: 2020-12-22 02:27
There is already a solution:

When putting the function into a separate file and import it in the main file, there is no error at all.


def f(x):
    return x*x


from multiprocessing import Pool
import defs

if __name__ == '__main__':
    with Pool(5) as p:
        print(, [1, 2, 3]))
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86874
2020-12-22 02:27:31reeyarnsetstatus: open -> closed
resolution: not a bug
messages: + msg383567

stage: resolved
2020-12-22 02:00:48reeyarncreate