cv2.solvepnpransac too many values to unpack code example
Example: cv2.solvepnpransac too many values to unpack
So it might help to try out:
_, rvecs, tvecs, inliers = cv2.solvePnPRansac(objp, corners2, mtx, dist)
or in case you just want to unpack the last 3 elements:
rvecs, tvecs, inliers = cv2.solvePnPRansac(objp, corners2, mtx, dist)[:-3]