openai/multiagent-particle-envs

Fix: ImportError: cannot import name 'prng'

zhaolongkzz opened this issue ยท 3 comments

The problem of prng is that the gym package is updating, and prng function has been deleted.

you can fix this in code multiagent-particle-envs/multiagent/multi_discrete.py

import gym
# from gym.spaces import prng             # this prng has been canceled

and change this line with:

np_random = np.random.RandomState()
random_array = np_random.rand(self.num_discrete_space)
0aqz0 commented

The version of gym is not correct. You can fix it by

pip uninstall gym
pip install gym==0.10.5

@0aqz0 yes, the above is what I offered to solve this problem.

The prng in gym 0.10.x is actually a wrapper of numpy.random. In "prng.py", there is
np_random = numpy.random.RandomState()

So instead of downgrading gym, I'd prefer to edit the file "multiagent-particle-envs\multiagent\multi_discrete.py" like this,

# from gym.spaces import prng  # comment this line

# random_array = prng.np_random.rand(self.num_discrete_space)  # replace this with following one
random_array = np.random.RandomState().rand(self.num_discrete_space)