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

Seeking Help for "ValueError: too many values to unpack" Issue in Python Program #736

Open
ZhShihang opened this issue Dec 11, 2023 · 1 comment

Comments

@ZhShihang
Copy link

ZhShihang commented Dec 11, 2023

Hello everyone,

I hope you're doing well. I am a Python program user and have recently encountered a challenging issue while working on my project. I am getting the following error, and despite trying various solutions, I haven't been able to resolve it:

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.3.3\plugins\python\helpers\pydev\pydevd.py", line 1496, in exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2022.3.3\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\main.py", line 786, in
algorithms.eaMuPlusLambda(population, toolbox, mu=100, lambda
=200, cxpb=0.7, mutpb=0.2, ngen=ngen, stats=None,
File "C:\deap\algorithms.py", line 316, in eaMuPlusLambda
offspring = varOr(population, toolbox, lambda_, cxpb, mutpb)
File "C:\deap\algorithms.py", line 239, in varOr
ind, = toolbox.mutate(ind)
ValueError: too many values to unpack (expected 1)

I've tried several approaches, but the issue persists. I'm reaching out to the community for assistance. If any developers here have insights into the possible causes of this "ValueError," or if you've encountered a similar situation before, I would greatly appreciate any advice or solutions you can offer.
Thank you so much for your time and assistance!

@fengyangsun
Copy link

It seems you return too many variables with the function. You could try this line as:
ind = toolbox.mutate(ind)
Note: without the comma
Another thing is, you may have already defined your own mutate function without the comma, in which case you need to add it in function definition so you don't have to change other things.

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

2 participants