1

I know that this questions seems repeated but the existing questions didn't apply to my case. I don't have any file named multiprocess.pool in my directory and I still get this error when trying to run the traffic generator.

Traceback (most recent call last):
  File "run.py", line 1, in <module>
    import generator
  File "/home/alaa/synthetic_traffic_generator-master/synthetic_traffic_generator-master/generator.py", line 13, in <module>
    from multiprocessing.pool import Pool, Process
ImportError: cannot import name 'Process' from 'multiprocessing.pool' (/usr/lib/python3.8/multiprocessing/pool.py)

This is the part of the code where it uses Process:

def generate_synthethic_users_and_traffic(number_of_users=NUMBER_OF_SYNTHETIC_USERS):
# Makes the random numbers predictable, to make the experiment reproducible.
seed(1234)
user_generator = UserDistribution(number_of_users)
# generate_and_write_synthetic_traffic is a very light method, thus it
# is not necessary to create a pool of processes and join them later on
for user in user_generator.users():
    Process(target=user.generate_and_write_synthetic_traffic).start()

I believe this parts needs to be updated by I have no idea how. Any help with this issue is appreciated. Thanks in advance.

EDIT:

I followed the first answer and now the error changed to this:

   Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/alaa/synthetic_traffic_generator-master/synthetic_traffic_generator-master/generator.py", line 348, in generate_and_write_synthetic_traffic
    self.generate_synthetic_traffic()
  File "/home/alaa/synthetic_traffic_generator-master/synthetic_traffic_generator-master/generator.py", line 265, in generate_synthetic_traffic
    for hour, traffic_model in self.traffic_model_per_hour.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

EDIT 2: I followed this question to solve the second issue and now it works.

Alaa
  • 539
  • 3
  • 8
  • 29

1 Answers1

2

There is no multiprocessing.pool.Process And the Github Repository you are following is 7 Years Old! Which hasn't been updated since then. And not compatible with the current version of python So, it's obvious to expect errors like this. But,

You can try replacing that import code block in generator.py line 13 which is from multiprocessing.pool import Pool, Process delete that line and add the followings:

from multiprocessing import Pool, Process
  • Thanks for your answer, I did what you said and now the error changed. Can you please check the edit on my post? I know that the repository is 7 years old but I need it in my work that is why I trying to solve this issue. – Alaa Dec 22 '21 at 08:32
  • 1
    Python3 renamed `dict.iteritems -> dict.items` just change `.iteritems()` with `.items()`in line `265` in `generator.py` if i'm right. – Aiden Ellis Dec 22 '21 at 08:42