3
$\begingroup$

I have installed a Python 3.7.2, download anaconda and visual studio code. Install Qiskit SDK 0.5.3. But when I launch my first test program from https://github.com/Qiskit/qiskit-terra I received a couple of messages like

{
"message": "Instance of 'QuantumCircuit' has no 'h' member",
"message": "Instance of 'QuantumCircuit' has no 'cx' member",
"message": "Instance of 'QuantumCircuit' has no 'measure' member",
}

What I do wrong?

This is my code:

from qiskit import *
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.h(q[0])
qc.cx(q[0], q[1])
qc.measure(q, c)
backend_sim = BasicAer.get_backend('qasm_simulator')
result = execute(qc, backend_sim).result()
print(result.get_counts(qc))
$\endgroup$
4
$\begingroup$

These messages pop up in the linter due to the way gates are dynamically added as circuit attributes in Qiskit Terra. They can safely be ignored. In a future update of Terra these warnings will disappear.

$\endgroup$
2
$\begingroup$

The problem was at linter.

It's necessary to add

 "python.linting.pylintArgs": [
        "--disable=E1101"
    ]

to the settings.json.

$\endgroup$
  • 1
    $\begingroup$ disabling linting is not necessarily a good idea, as you also lose potentially useful messages. If the linting is not detecting the methods of qc it might be because the shell used by vscode in the background is not using the python distribution/environment in which qiskit is installed $\endgroup$ – glS Mar 15 at 10:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.