Reputation: 1
I am trying some simple programs which involve multiprocessing features in Python.
from multiprocessing import Process, Queue
def print_square(i):
print i*i
if __name__ == '__main__':
output = Queue()
processes = [Process(target=print_square,args=(i,)) for i in range(5)]
for p in processes:
p.start()
for p in processes:
p.join()
However, this gives an error message AttributeError: 'module' object has no attribute 'heappush'.
The complete output upon executing the script is given below:
Traceback (most recent call last): File "parallel_3.py", line 15, in output = Queue() File "C:\Users\abc\AppData\Local\Continuum\Anaconda2\lib\multi processing\__init__.py", line 217, in Queue from multiprocessing.queues import Queue File "C:\Users\abc\AppData\Local\Continuum\Anaconda2\lib\multi processing\queues.py", line 45, in from Queue import Empty, Full File "C:\Users\abc\AppData\Local\Continuum\Anaconda2\lib\Queue .py", line 212, in class PriorityQueue(Queue): File "C:\Users\abc\AppData\Local\Continuum\Anaconda2\lib\Queue .py", line 224, in PriorityQueue def _put(self, item, heappush=heapq.heappush): AttributeError: 'module' object has no attribute 'heappush'
The code compiles fine if the output=Queue() statement is commented. What could be possibly causing this error ?
Upvotes: 0
Views: 4030
Reputation: 21
Your filename should be the package name. Change to another filename such as heap
and it will work.
Upvotes: 2