Error : coefficients entering the QubitOperator must be real

Dear All,

Sometimes while running adaptive circuit or molecular geometry optimization tutorial using molecules like water, I get the following error.

“The coefficients entering the QubitOperator must be real; got complex coefficients in the operator”.

I am not sure how to overcome this error, can you kindly help.

Thank you

Hi @raghavv, are you changing something in the tutorials? Or maybe you’re changing the virtual environment they’re running on?

Thank you @CatalinaAlbornoz for your kind response. There are times when I tried to modify the tutorial code and and at times I did not. But in both the cases I get the error sometimes. Basically I am trying to do the calculation for bigger molecules like water. What do you think could be a problem.

Thank you

Hi @raghavv, could you please share the code you’re using? You should be able to upload it here as a .py file.

Also, what versions of PennyLane, pennylane-qchem and Python are you using?

1 Like

@CatalinaAlbornoz. Sorry for the delayed response . Thank you for your reply. I will share the details at the earliest.

Thank you

Thank you @raghavv! If you have trouble uploading the .py file you can copy-paste the code here. I’m happy to help.