I'm using this simple code to test my Qiskit and learn how to use it but it keeps giving this problems, how do I fix it (Using VS Code and Anaconda Python 3.7)

import numpy as np
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
# Create a Quantum Register with 3 qubits.Basicaly creating the number of qubits your system will use
q = QuantumRegister(3, 'q')
# Create a Quantum Circuit acting on the q register. Declaring the Circuit, this circuit shall create a GHZ state
circ = QuantumCircuit(q,)
# Add a H gate on qubit 0, putting this qubit in superposition.
# Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting
# the qubits in a Bell state.
circ.cx(q[0], q[1])
# Add a CX (CNOT) gate on control qubit 0 and target qubit 2, putting
# the qubits in a GHZ state.
circ.cx(q[0], q[2])
#Draws the circuit
from qiskit.tools.visualization import circuit_drawer

enter image description here


2 Answers 2


There are no errors in your program.

Pylint is a static code analysis tool and sometimes it gets confused and emits false positives. In this case, gate methods (h, cx and others) are added to QuantumCircuit dynamically at a later point, so Pylint cannot detect them. See qiskit.extensions.standard if you'd like to learn how this works.

The simplest “fix” for this “error” is making Pylint ignore those classes in your pylintrc (if your installation of Pylint comes pre-built into your IDE, you'll have to see if the IDE has some particular way of configuring Pylint).


# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.

I guess you are following the code from the notebook getting_started_with_qiskit_terra. However it should be

circ = QuantumCircuit(q) 

instead of

circ = QuantumCircuit(q,)

according to this notebook. Can you try removing the coma and running?

  • $\begingroup$ Trailing commas are generally allowed in Python, including in function/class calls. $\endgroup$
    – Norrius
    Dec 15, 2018 at 10:30
  • $\begingroup$ Did not know that. It is ugly though. $\endgroup$
    – cnada
    Dec 15, 2018 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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