I'm trying to install cirq_ionq, a python library for running cirq circuits on IonQ's quantum hardware. However, when I try importing it I get an unexpected argument error:

!pip install cirq-ionq
import cirq_ionq
<ipython-input-8-d96952276b12> in <module>
      1 get_ipython().system('pip install cirq-ionq')
----> 2 import cirq_ionq

1 frames
/usr/local/lib/python3.7/dist-packages/cirq_ionq/ionq_devices.py in <module>
     32     cirq.MeasurementGate,
     33     unroll_circuit_op=False,
---> 34     accept_global_phase_op=False,
     35 )

TypeError: __init__() got an unexpected keyword argument 'accept_global_phase_op'

I am confused why I am getting an unexpected argument error. I'm not calling a constructor, I am importing a library, right?

Could someone please explain this to me? I appreciate it.

  • $\begingroup$ You probably have a mismatch of cirq-core and cirq-ionq versions on your system. What do you get when you pip show cirq-core and pip show cirq-ionq? $\endgroup$ Sep 14, 2022 at 15:51
  • $\begingroup$ docs.google.com/document/d/…. The first image. I also have a code in google colab before code in SE question, which is in second image. That code returns a checkmark, likely because I already run it $\endgroup$ Sep 14, 2022 at 16:21
  • $\begingroup$ Looks like yourcirq-core and cirq-ionq versions match at 0.14.1 so that's not the problem. What happens if you pip install --upgrade cirq-ionq and try the importing cirq-ionq` again. This command should give you cirq-ionq==1.0.0. $\endgroup$ Sep 14, 2022 at 16:37
  • $\begingroup$ Yes! It works! Thanks so much, I appreciate your time. But if I may ask, why wasn't it working before? $\endgroup$ Sep 14, 2022 at 18:42
  • $\begingroup$ I can't know the cause without studying more than what you've posted, but my guess is that the install got messed up somewhere. We just installed the latest version of cirq-ionq just for testing to do a whole new install. Does the import still work if you do !pip install cirq-ionq~=0.14.1? $\endgroup$ Sep 14, 2022 at 18:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.