Ask Your Question
0

ValueError:need more than 3 values to unpack

asked 2017-11-02 10:35:40 -0600

gursx gravatar image

updated 2017-11-02 10:55:30 -0600

Hi there. I'm testing a script i found on GitHub, but i keep getting a ValueError:

ValueError:need more than 3 values to unpack

Thats the complicated line in the script:

(CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2) = cv2.__version__.split(".")

I am using OpenCv 3.3.0 and i already read that the Syntax has changed with 3.0 release, but i still can not solve this problem. I changed this line already to:

CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2 = cv2.__version__.split(".")

But im stil getting the Value Error. Any help is appreciated.

edit retag flag offensive close merge delete

Comments

What is the error message?

supra56 gravatar imagesupra56 ( 2017-11-02 10:49:08 -0600 )edit

ValueError:need more than 3 values to unpack

gursx gravatar imagegursx ( 2017-11-02 10:50:52 -0600 )edit

I needed to see error message..eg in line x

supra56 gravatar imagesupra56 ( 2017-11-02 11:03:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-11-02 11:18:00 -0600

1. Inspect First

Printing out the value of cv2.__version__ first before assigning it.

By doing so in my machine, I got the value

3.3.0-dev

From here you can tell that you actually need three variables instead of four hence

major_version, minor_version, type = cv2.__version__.split('.')

should work just fine.

2. Dynamic

In the event that you do not have the luxury of doing a quick check of your results, you can refer back to native Python APIs.

result = cv2.__version__.split('.')

split() returns a list consisting of the substrings.

From here, result consists of

['3', '3', '0-dev']

Example usage of split()

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-02 10:35:40 -0600

Seen: 1,430 times

Last updated: Nov 02 '17