Unity-Technologies / obstacle-tower-challenge

Starter Kit for the Unity Obstacle Tower challenge
Apache License 2.0
119 stars 39 forks source link

AttributeError: module 'gym' has no attribute 'Env' #35

Open saitanya opened 5 years ago

saitanya commented 5 years ago

I am running run.py and I get the following error. class ObstacleTowerEnv(gym.Env): AttributeError: module 'gym' has no attribute 'Env'

How do I resolve this?

galatolofederico commented 4 years ago

I have just stumbled upon the same issue. Probably the problem is that you are using gym as file (or folder) name and so overwriting the imported gym. Changing the filename will do the trick. Check this example out

(env) [federico@nicebox test]$ cat gym.py
import gym
env = gym.make('CartPole-v0')
for i_episode in range(20):
    observation = env.reset()
    for t in range(100):
        env.render()
        print(observation)
        action = env.action_space.sample()
        observation, reward, done, info = env.step(action)
        if done:
            print("Episode finished after {} timesteps".format(t+1))
            break
env.close()
(env) [federico@nicebox test]$ python gym.py
Traceback (most recent call last):
  File "gym.py", line 1, in <module>
    import gym
  File "/tmp/test/gym.py", line 2, in <module>
    env = gym.make('CartPole-v0')
AttributeError: module 'gym' has no attribute 'make'
(env) [federico@nicebox test]$ mv gym.py newname.py
(env) [federico@nicebox test]$ python newname.py
[-0.03970486  0.02212319  0.01405992  0.03092198]
[-0.0392624   0.21704072  0.01467836 -0.25729194]
[-0.03492158  0.41195007  0.00953252 -0.54530919]
[-0.02668258  0.60693679 -0.00137366 -0.83497346]
[-0.01454385  0.41183363 -0.01807313 -0.54272285]