dhruvp / atari-pong

Neural Networks For Playing Pong
77 stars 51 forks source link

Running me_pong.py or pong.py on MacOs the attached error occurs #1

Open marcogdepinto opened 6 years ago

marcogdepinto commented 6 years ago
/usr/local/bin/python3.6 /Users/marcogdepinto/PycharmProjects/PlayPong/me_pong.py
2018-05-12 15:56:40.341 Python[3463:35840] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
  File "/Users/marcogdepinto/PycharmProjects/PlayPong/me_pong.py", line 236, in <module>
    main()
  File "/Users/marcogdepinto/PycharmProjects/PlayPong/me_pong.py", line 212, in main
    episode_gradient_log_ps_discounted = discount_with_rewards(episode_gradient_log_ps, episode_rewards, gamma)
  File "/Users/marcogdepinto/PycharmProjects/PlayPong/me_pong.py", line 140, in discount_with_rewards
    discounted_episode_rewards = discount_rewards(episode_rewards, gamma)
  File "/Users/marcogdepinto/PycharmProjects/PlayPong/me_pong.py", line 130, in discount_rewards
    for t in reversed(xrange(0, rewards.size)):
NameError: name 'xrange' is not defined
Exception ignored in: <bound method SimpleImageViewer.__del__ of <gym.envs.classic_control.rendering.SimpleImageViewer object at 0x10acd00b8>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 347, in __del__
  File "/usr/local/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 343, in close
  File "/usr/local/lib/python3.6/site-packages/pyglet/window/cocoa/__init__.py", line 281, in close
  File "/usr/local/lib/python3.6/site-packages/pyglet/window/__init__.py", line 770, in close
**ImportError: sys.meta_path is None, Python is likely shutting down**
wokkel23 commented 5 years ago

Greetings,

I had the same problem, but I solved it: In line 120 xrange is used. In Python 3.x, the xrange function does not exist anymore. The range function now does what xrange does in Python 2.x, so to keep your code portable, you might want to stick to using range instead.