I recently downloaded Anaconda(Python 3.7) on Windows 10 and I am having difficulty importing Qiskit in jupyter notebook. I tried the following line:

import qiskit

And got the following Error Traceback:

OSError                                   Traceback (most recent call last)
<ipython-input-5-44fa2f0c0a47> in <module>
      1 # !pip install qiskit
----> 2 import qiskit
      3 # from ctypes import *
      4 # qiskit.__qiskit_version__

C:\ProgramData\Anaconda3\lib\site-packages\qiskit\__init__.py in <module>
     31 # The main qiskit operators
---> 32 from qiskit.circuit import ClassicalRegister
     33 from qiskit.circuit import QuantumRegister
     34 from qiskit.circuit import QuantumCircuit

C:\ProgramData\Anaconda3\lib\site-packages\qiskit\circuit\__init__.py in <module>
    217 from .classicalregister import ClassicalRegister, Clbit
    218 from .quantumregister import QuantumRegister, Qubit
--> 219 from .gate import Gate
    220 # pylint: disable=cyclic-import
    221 from .controlledgate import ControlledGate

C:\ProgramData\Anaconda3\lib\site-packages\qiskit\circuit\gate.py in <module>
     17 from typing import List, Optional, Union, Tuple
     18 import numpy as np
---> 19 from scipy.linalg import schur
     21 from qiskit.circuit.exceptions import CircuitError

C:\ProgramData\Anaconda3\lib\site-packages\scipy\__init__.py in <module>
    103 # Allow distributors to run custom init code
--> 104 from . import _distributor_init
    106 __all__ += _num.__all__

C:\ProgramData\Anaconda3\lib\site-packages\scipy\_distributor_init.py in <module>
     59             os.chdir(libs_path)
     60             for filename in glob.glob(os.path.join(libs_path, '*dll')):
---> 61                 WinDLL(os.path.abspath(filename))
     62         finally:
     63             os.chdir(owd)

C:\ProgramData\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: [WinError 126] The specified module could not be found

I also recently installed qiskit in the Anaconda Prompt, as the traceback indicates, and as indicated the root of the error exists in ctypes library.

Could someone please assist me in getting qiskit to run.

  • $\begingroup$ I think this may be an issue with Anaconda. You could try running conda env update while inside this environment to see if it fixes anything, but if it doesn't a reinstall of Anaconda might be the easiest solution $\endgroup$ – Matthew Stypulkoski Jun 29 at 14:18
  • $\begingroup$ The error seems to be coming from scipy, you can try to re-install that !pip install —upgrade scipy (or without the upgrade option if it is not yet installed) $\endgroup$ – Cryoris Jun 29 at 14:29
  • 1
    $\begingroup$ @MatthewStypulkoski I reinstalled Anaconda and Qiskit and it worked, thanks. $\endgroup$ – MShakeG Jun 29 at 15:20

It is possible that the environment (kernel) at which you downloaded qiskit is not the same kernel you're currently using to import qiskit. Try to pick the right kernel from the Kernel tab in the Jupyter notebook menu. It's also recommended to use virtual environments to better handle this. Take a look at the installation guidelines published by Qiskit.

| improve this answer | |

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.