Ask Your Question

how to solve this problem ? SyntaxError: only named arguments may follow *expression

asked 2017-11-13 23:22:24 -0600

soro gravatar image

i am making a project with python but i am new in python3 opencv. i got this error when trying to run. gray = gray.reshape(*gray.shape,1) SyntaxError: only named arguments may follow *expression what is the best way to deal with?

the part the code is gray = rgb2gray(cropped) gray = gray.reshape(gray.shape,1) and when i run i got gray = gray.reshape(gray.shape,1) SyntaxError: only named arguments may follow *expression

edit retag flag offensive close merge delete


which python version is it, exactly ?

and how is this related to opencv ?

berak gravatar imageberak ( 2017-11-14 00:25:48 -0600 )edit

i am using python3.5 with opencv 3.3 i tried it in ubuntu terminal it does not work but there was not error message. so for debugging purpose i tried with eclipse pydev and that helped me to see the error message

i include opencv libraries in the eclipse C++/C IDE. i also compiled opencv with python3 .5

soro gravatar imagesoro ( 2017-11-14 01:59:50 -0600 )edit

thing is, it works with python 3.5.2

imho, you should avoid this construct entirely, and use

gray.reshape(gray.shape[0], gray.shape[1], 1)

instead (do your own unpacking)

and again, not at all an opencv problem, plain python/numpy syntax one !

berak gravatar imageberak ( 2017-11-14 02:13:44 -0600 )edit

ok thank , that seems to be ok

soro gravatar imagesoro ( 2017-11-14 05:42:10 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-11-14 05:53:41 -0600

supra56 gravatar image
gray = gray.reshape((-1,1))
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-11-13 23:22:03 -0600

Seen: 399 times

Last updated: Nov 14 '17