To get rid of import error name the file something else instead of multiprocessing.py, as filename should not be same as module name.
You will be able to import the Pool function after a change of filename and your code should work on python3. But if you are using python2 the code will not work.
In Python 2.x and 3.0, 3.1 and 3.2, multiprocessing.Pool() objects are not context managers. You cannot use them in a with the statement. Only in Python 3.3 and up can you use them as such.
From the Python 3 multiprocessing.Pool() documentation:
New in version 3.3: Pool objects now support the context management
protocol – see Context Manager Types. enter() returns the pool
object, and exit() calls terminate().
Below code will work on python2
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
p = Pool(5)
print(p.map(f, [1, 2, 3]))
Output
[1, 4, 9]