multiagent-particle-envs
multiagent-particle-envs copied to clipboard
AttributeError: 'NoneType' object has no attribute 'flip'
Traceback (most recent call last):
File "D:/My_Research/MAS_code/Python/multiagent-particle-envs-master/bin/interactive.py", line 36, in
Process finished with exit code 1
Did anyone fix this issue?
I'm actually having a similar issue and am unsure how to solve it. It works for some files but not for others, all of which are the same type of file.
Traceback (most recent call last): File "D:/My_Research/MAS_code/Python/multiagent-particle-envs-master/bin/interactive.py", line 36, in env.render() File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\environment.py", line 261, in render results.append(self.viewers[i].render(return_rgb_array = mode=='rgb_array')) File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\rendering.py", line 110, in render self.window.flip() File "C:\Python27\lib\site-packages\pyglet\window\win32__init__.py", line 323, in flip self.context.flip() AttributeError: 'NoneType' object has no attribute 'flip'
Process finished with exit code 1
Did anyone fix this issue?
I had this problem as well, but could solve it: in the first section of train.py file:
parser.add_argument("--exp-name", type=str, default=None, help="name of the experiment")
The Nontype error .... stems from None in the default here. Define a name for it as a string for example "apple1" and it w ill save .pkl file with that name and solve the error.
For some files it works because it might pass something upon calling (instead of the default).
the below part in train.py shows these names and string definitions are used in saving info for plotting and rendering:
in the final sections of train.py: # saves final episode reward for plotting training curve later if len(episode_rewards) > arglist.num_episodes: rew_file_name = arglist.plots_dir + arglist.exp_name + '_rewards.pkl' with open(rew_file_name, 'wb') as fp: pickle.dump(final_ep_rewards, fp)
since : arglist = parse_args() #under main in train.py defining arglist.plots_dir and arglist.exp_name under parse_args() will help solving the issues.
I'm actually having a similar issue and am unsure how to solve it. It works for some files but not for others, all of which are the same type of file.
Please try what I mentioned!
I'm an otherwise lay-person (the intersection of my field with building programs is somewhat oblique), so bear with me. I have found the root cause and have solved it.
To troubleshoot, I printed the names of each file read in a folder. I saw all of the files I expected. On the folders in which the script would not work, I saw an extra file named "Thumbs.db". I couldn't see the file in the windows explorer, so I am guessing it is sometimes hidden in folders and sometimes it isn't present at all.
So the root cause (I think) was the presence of a hidden file of a type that actually did not have the attribute. I fixed it by specifying what type of file extension the script would operate on (so in the presence of hidden files, it would still work).
@mkouzehgar Does any of this comport with what you mentioned earlier? I'm asking because I solved this last Monday and am now seeing your reply.
Traceback (most recent call last): File "D:/My_Research/MAS_code/Python/multiagent-particle-envs-master/bin/interactive.py", line 36, in env.render() File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\environment.py", line 261, in render results.append(self.viewers[i].render(return_rgb_array = mode=='rgb_array')) File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\rendering.py", line 110, in render self.window.flip() File "C:\Python27\lib\site-packages\pyglet\window\win32__init__.py", line 323, in flip self.context.flip() AttributeError: 'NoneType' object has no attribute 'flip' Process finished with exit code 1 Did anyone fix this issue?
I had this problem as well, but could solve it: in the first section of train.py file:
parser.add_argument("--exp-name", type=str, default=None, help="name of the experiment")
The Nontype error .... stems from None in the default here. Define a name for it as a string for example "apple1" and it w ill save .pkl file with that name and solve the error.
For some files it works because it might pass something upon calling (instead of the default).
the below part in train.py shows these names and string definitions are used in saving info for plotting and rendering:
in the final sections of train.py: # saves final episode reward for plotting training curve later if len(episode_rewards) > arglist.num_episodes: rew_file_name = arglist.plots_dir + arglist.exp_name + '_rewards.pkl' with open(rew_file_name, 'wb') as fp: pickle.dump(final_ep_rewards, fp)
since : arglist = parse_args() #under main in train.py defining arglist.plots_dir and arglist.exp_name under parse_args() will help solving the issues.
Traceback (most recent call last): File "D:/My_Research/MAS_code/Python/multiagent-particle-envs-master/bin/interactive.py", line 36, in env.render() File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\environment.py", line 261, in render results.append(self.viewers[i].render(return_rgb_array = mode=='rgb_array')) File "D:\My_Research\MAS_code\Python\multiagent-particle-envs-master\bin..\multiagent\rendering.py", line 110, in render self.window.flip() File "C:\Python27\lib\site-packages\pyglet\window\win32__init__.py", line 323, in flip self.context.flip() AttributeError: 'NoneType' object has no attribute 'flip' Process finished with exit code 1 Did anyone fix this issue?
I had this problem as well, but could solve it: in the first section of train.py file:
parser.add_argument("--exp-name", type=str, default=None, help="name of the experiment")
The Nontype error .... stems from None in the default here. Define a name for it as a string for example "apple1" and it w ill save .pkl file with that name and solve the error.
For some files it works because it might pass something upon calling (instead of the default).
the below part in train.py shows these names and string definitions are used in saving info for plotting and rendering:
in the final sections of train.py: # saves final episode reward for plotting training curve later if len(episode_rewards) > arglist.num_episodes: rew_file_name = arglist.plots_dir + arglist.exp_name + '_rewards.pkl' with open(rew_file_name, 'wb') as fp: pickle.dump(final_ep_rewards, fp)
since : arglist = parse_args() #under main in train.py defining arglist.plots_dir and arglist.exp_name under parse_args() will help solving the issues.
Hello. I tried this but do not get it to work yet. The command to run it is 'python interactive.py --scenario simple.py' within the bin folder, isn't it? Also, could you please explain to me the relationship between this code and train.py which is in a different folder? Maybe I am running it incorrectly.
Thank you in advance
Have you fixed this issue?