3
$\begingroup$

I have successfully installed qiskit. However, when I try to run a simulation I get the error "No module named 'qiskit'

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute

How can I get or enable this module?

$\endgroup$
1
$\begingroup$

Just install by using pip package pip3 install qiskit You can find the pip3.exe under the python installation.

$\endgroup$
0
$\begingroup$

Try command pip install qiskit or pip3 install qiskit in cmd or Anaconda Prompt to install the qiskit module. Then try running the command you used.

If it's still not working check whether your notebook is working in the same location where you installed the qiskit module.

Tip: Use from qiskit import * as it saves time and imports all the packages in qiskit.

Alternative: You can also use the jupyter notebook in IBM Quantum Experience.

$\endgroup$
1
  • 1
    $\begingroup$ Note that the construct from [package] import * is considered to be a bad practice in Python as it might imports a lot of things into the global namespace and it makes the code less readable (if you have 2 such constructs, someone that does not know the packages have no way of finding which one included the thing he/she is interested in). $\endgroup$ Jul 13 at 8:44
0
$\begingroup$

I believe this is a path issue. As already mentioned

pip3 install qiskit

will install the full package and configure the paths for you.

You can find the search paths for all Python modules by

import sys
print(sys.path)

If the full path to your Qiskit package is full/path/to/qiskit and '/full/path/to' is not in sys.path, then you need to append it by

sys.path.append('full/path/to')

in the script you are running. If you are running on Linux, you can write

export PYTHONPATH=/full/path/to:$PYTHONPATH

in the .bashrc file so that you don't need to set the path every time.

$\endgroup$

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.