2

I ran this

from qiskit import QuantumCircuit, execute, Aer
from qiskit.visualization import plot_histogram

and got the below error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-07258f5373b7> in <module>
----> 1 from qiskit import QuantumCircuit, execute, Aer
      2 from qiskit.visualization import plot_histogram

~\AppData\Roaming\Python\Python37\site-packages\qiskit\__init__.py in <module>
     55 # Try to import the Aer provider if installed.
     56 try:
---> 57     from qiskit.providers.aer import Aer
     58 except ImportError:
     59     suppress_warnings = os.environ.get('QISKIT_SUPPRESS_PACKAGING_WARNINGS', '')

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\__init__.py in <module>
     62 
     63 # pylint: disable=wrong-import-position
---> 64 from .aerprovider import AerProvider
     65 from .aerjob import AerJob
     66 from .aererror import AerError

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\aerprovider.py in <module>
     21 from .backends.statevector_simulator import StatevectorSimulator
     22 from .backends.unitary_simulator import UnitarySimulator
---> 23 from .backends.pulse_simulator import PulseSimulator
     24 
     25 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\backends\__init__.py in <module>
     18 from .statevector_simulator import StatevectorSimulator
     19 from .unitary_simulator import UnitarySimulator
---> 20 from .pulse_simulator import PulseSimulator

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\backends\pulse_simulator.py in <module>
     24 from ..version import __version__
     25 from ..aererror import AerError
---> 26 from ..pulse.controllers.pulse_controller import pulse_controller
     27 from ..pulse.system_models.pulse_system_model import PulseSystemModel
     28 from .aerbackend import AerBackend

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\__init__.py in <module>
     50 from .qutip_extra_lite.cy import pyxbuilder as pbldr
     51 
---> 52 from .system_models.duffing_model_generators import duffing_system_model
     53 from .system_models.pulse_system_model import PulseSystemModel
     54 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\system_models\duffing_model_generators.py in <module>
     19 from collections.abc import Iterable
     20 from qiskit.providers.models.backendconfiguration import UchannelLO
---> 21 from .hamiltonian_model import HamiltonianModel
     22 from .pulse_system_model import PulseSystemModel
     23 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\system_models\hamiltonian_model.py in <module>
     20 import numpy.linalg as la
     21 from ...aererror import AerError
---> 22 from .string_model_parser.string_model_parser import HamiltonianParser
     23 
     24 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\system_models\string_model_parser\string_model_parser.py in <module>
     21 import numpy as np
     22 from .apply_str_func_to_qobj import apply_func
---> 23 from .qobj_from_string import gen_oper
     24 
     25 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\system_models\string_model_parser\qobj_from_string.py in <module>
     16 """Module for creating quantum operators."""
     17 
---> 18 from ...qutip_extra_lite import qobj_generators
     19 
     20 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\qutip_extra_lite\qobj_generators.py in <module>
     17 
     18 import numpy as np
---> 19 from . import operators as ops
     20 from . import states as st
     21 from . import tensor as ten

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\qutip_extra_lite\operators.py in <module>
     54 
     55 import numpy as np
---> 56 from .fastsparse import fast_csr_matrix, fast_identity
     57 from .qobj import Qobj
     58 

~\AppData\Roaming\Python\Python37\site-packages\qiskit\providers\aer\pulse\qutip_extra_lite\fastsparse.py in <module>
    438 # -------------------------------------
    439 # pylint: disable=no-name-in-module, wrong-import-position, import-error
--> 440 from .cy.spmath import (zcsr_transpose, zcsr_adjoint, zcsr_mult)

spmath.pyx in init qiskit.providers.aer.pulse.qutip_extra_lite.cy.spmath()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Any idea?

I installed numpy 1.16/1.17 and the latest one, still error is the same.
python - 3.7.9 I run ML projects so versions are vital

X10nD
  • 21,638
  • 45
  • 111
  • 152

2 Answers2

2

This is because the latest Qiskit Aer (0.7.4, Qiskit meta 0.23.5) was compiled with numpy 1.20.0, which is incompatible with older versions of numpy. See this issue: https://github.com/Qiskit/qiskit-aer/issues/1120 for more details.

The workaround for now is to upgrade your numpy to 1.20.0.

jyu00
  • 181
  • 1
1

It sees like your installation is broken somehow. Did you try reinstalling?

pip install --ignore-installed qiskit-terra qiskit-aer
luciano
  • 399
  • 4
  • 13
  • 1
    I got this 'ERROR: [pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tensorflow 2.4.1 requires numpy~=1.19.2, but you have numpy 1.20.1 which is incompatible.'] but running import qiskit still got me the above error – X10nD Feb 14 '21 at 09:36
  • well.. there you have. qiskit and tensorflow have conflicting dependencies. You should install them in different venvs. – luciano Feb 14 '21 at 09:51
  • And I upgraded the numpy from 1.18 to 1.19.2 and still the same errors. – X10nD Feb 15 '21 at 06:12
  • ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject >>> import tensorflow as tf, numpy as np 2021-02-15 09:12:01.127018: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-02-15 09:12:01.127716: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. >>> print(tf.__version__, np.__version__) 2.4.1 1.19.2 – X10nD Feb 15 '21 at 06:31