Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'items' #129

Open
suleiman1122 opened this issue Feb 14, 2022 · 4 comments
Open

AttributeError: 'NoneType' object has no attribute 'items' #129

suleiman1122 opened this issue Feb 14, 2022 · 4 comments

Comments

@suleiman1122
Copy link

Hi,
when I run the code from ubuntu 20 python 3.6 I got this error

File "src/main.py", line 88, in
config_dict = recursive_dict_update(config_dict, alg_config)
File "src/main.py", line 56, in recursive_dict_update
for k, v in u.items():
AttributeError: 'NoneType' object has no attribute 'items'

@bayzhen
Copy link

bayzhen commented Jun 1, 2022

me,too

@8uttonwoodRL
Copy link

Do you Solved it

@suleiman1122
Copy link
Author

suleiman1122 commented Dec 18, 2022 via email

@qxy-commits
Copy link

Learn about the sys.argv command from this website: https://blog.csdn.net/Kim_Weir/article/details/103875186
You can think of argv as a list, the first element is the location of main.py, followed by the external parameters.
params = deepcopy(sys.argv)
This command receives parameters entered from the terminal, for example
python3 src/main.py --config=qmix --env-config=sc2 with env_args.map_name=2s3z
So, when you click the debug or run button directly in pycharm, there is only one element in the argv list, which is the location of main.py. So params is wrong at this time.
So the result of env_config = _get_config(params, "sc2", "envs") is also wrong.
So the input parameter "env_config" of config_dict = recursive_dict_update(config_dict, env_config) is also wrong.
So the recursive_dict_update function will report an error.
I changed it to the following form. This form needs to be changed in the corresponding position in the code when changing the environment, map, and algorithm.

env_config = _get_config(params, "sc2", "envs")
def _get_config(params, arg_name, subfolder):
config_name = arg_name
if config_name is not None:
with open(os.path.join(os.path.dirname(file), "config", subfolder, "{}.yaml".format(config_name)), "r") as f:
try:
config_dict = yaml.load(f)
except yaml.YAMLError as exc:
assert False, "{}.yaml error: {}".format(config_name, exc)
return config_dict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants