问题描述
我跑了这个
from qiskit import QuantumCircuit, execute, Aer
from qiskit.visualization import plot_histogram
并得到以下错误
---------------------------------------------------------------------------
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
有什么想法吗?
我安装了numpy 1.16/1.17和最新的,还是一样的错误.
蟒蛇 - 3.7.9我运行机器学习项目,所以版本很重要
I installed numpy 1.16/1.17 and the latest one, still error is the same.
python - 3.7.9I run ML projects so versions are vital
推荐答案
这是因为最新的 Qiskit Aer (0.7.4, Qiskit meta 0.23.5) 是用 numpy 1.20.0 编译的,与旧版本的不兼容麻木.看到这个问题:https://github.com/Qiskit/qiskit-aer/issues/1120 了解更多详情.
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.
目前的解决方法是将您的 numpy 升级到 1.20.0.
The workaround for now is to upgrade your numpy to 1.20.0.
这篇关于QISKIT 错误 - numpy.ndarray 大小已更改,可能表示二进制不兼容.预期来自 C 头文件的 88,来自 PyObject 的 80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!