QISKIT 错误 - numpy.ndarray 大小已更改,可能表示二进制不兼容。预期来自 C 标头的值为 88,而来自 PyObject 的值为 80

2024-03-23

我跑了这个

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 我运行 ML 项目,因此版本至关重要


这是因为最新的 Qiskit Aer(0.7.4、Qiskit meta 0.23.5)是使用 numpy 1.20.0 编译的,与旧版本的 numpy 不兼容。看这个问题:https://github.com/Qiskit/qiskit-aer/issues/1120 https://github.com/Qiskit/qiskit-aer/issues/1120更多细节。

目前的解决方法是将 numpy 升级到 1.20.0。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

QISKIT 错误 - numpy.ndarray 大小已更改,可能表示二进制不兼容。预期来自 C 标头的值为 88,而来自 PyObject 的值为 80 的相关文章

  • Python 正则表达式从文本中提取域

    我有以下正则表达式 r a zA Z0 9 a zA Z0 9 61 a zA Z0 9 a zA Z 2 6 当我将其应用于文本字符串时 比方说 这是 www website1 com 这是 website2 com 我得到 www we
  • 如何从 Windows 7 PC 上完全卸载 Python 2.7

    从这里安装了Python 2 7 https www python org downloads release python 279 https www python org downloads release python 279 然后我
  • 来自多元 t 分布的样本 python

    我想知道Python中是否有一个从多元学生t分布中采样的函数 我有包含 14 个元素的均值向量 14x14 协方差矩阵和自由度 我想从这个 t 分布中采样一个向量 对于一维情况 我使用 stats t rvs df loc scale 并且
  • 在 Python 中倾斜数组

    我有一个 2D 数组 我将使用它保存为灰度图像scipy misc toimage 在此之前 我想将图像倾斜给定角度 像这样进行插值scipy ndimage interpolation rotate 上图只是为了说明倾斜过程 我知道我必须
  • R.scale() 和 sklearn.preprocessing.scale() 之间的区别

    我目前正在将数据分析从 R 转移到 Python 当在 R 中缩放数据集时 我将使用 R scale 根据我的理解 它将执行以下操作 x mean x sd x 为了替换该函数 我尝试使用 sklearn preprocessing sca
  • pandas groupby 并转换为 json 列表

    我有一个如下所示的 pandas 数据框 idx f1 f2 f3 1 a a b 2 b a c 3 a b c 87 e e e 我需要将其他列转换为基于索引列的字典列表 所以 最终结果应该是 idx features 1 f1 a f
  • Python3 - 如何将字符串转换为十六进制

    我正在尝试将字符串逐个字符转换为十六进制 但我无法在Python3中弄清楚它 在较旧的 python 版本中 我的以下内容有效 test This is a test for c in range 0 len test print 0x s
  • 错误:tensorflow:无法匹配检查点的文件

    我正在训练一个张量流模型 在每个时期之后我都会保存模型状态并腌制一些数组 到目前为止 我的模型执行了 2 个纪元 并且保存状态的文件夹包含以下文件 checkpoint model e knihy preprocessed txt e0 c
  • 无法使用 wxPython 打开在 folium 中生成的本地 HTML 文件

    我目前正在尝试将 GPS 坐标绘制为地图上的标记 并在 wxPython 中显示结果 我使用 folium 绘制坐标标记并生成 HTML 文件 import folium fmap folium Map 43 5321 172 6362 z
  • NumPy 根据另一个数组中的值对第三个数组中的每个匹配元素求和一个数组

    我有两个 numpy 数组 一个包含值 另一个包含每个值类别 values np array 1 2 3 4 5 6 7 8 9 10 valcats np array 101 301 201 201 102 302 302 202 102
  • Python 中的 Firebase 身份验证时出现 KeyError:“databaseURL”

    相信你做得很好 我是 firebase 的新手 正在尝试进行用户身份验证 我已经安装了pyrebase4并在firebase控制台上创建了一个项目 我还启用了使用 电子邮件和密码 登录并尝试连接我的应用程序 下面是我正在尝试的代码 impo
  • Python:两个列表之间的成对比较:列表 a >= 列表 b?

    如果我想检查列表中的所有元素 a 1 2 3 6 大于或等于另一个列表中对应的元素 b 0 2 3 5 如果 a i gt b i 对于所有i的 则返回 true 否则返回 false 这有逻辑功能吗 比如a gt b 谢谢 你可以这样做
  • 在解析器/子解析器的开头使用 argparse.REMAINDER

    我想实现一个 arg 解析器 它允许我将单元测试作为子命令之一运行 盲目地将参数传递给 unittest main 例如 foo py unittest args to pass to unittest main 以及其他子命令 foo p
  • Python-使用元组作为列表索引[重复]

    这个问题在这里已经有答案了 我有一个元组列表 tuples list 1 0 2 3 3 2 2 0 我想访问二维数组的元素a例如 使用其中一些元组 for i in range 3 print a tuples list i 应该输出的值
  • Python:Factory Boy 生成对象创建时指定长度的列表

    我正在尝试使用 Factoryboy 在创建时指定长度的对象中创建一个列表 我可以创建列表 但由于提供的长度 大小的惰性性质 每次尝试创建具有指定长度的列表都会导致问题 这是我到目前为止所拥有的 class FooFactory facto
  • Django - 渲染到字符串无法加载 CSS

    我正在尝试使用 Django 1 8 render to string 通过管理命令将 html 转换为 pdf 而不是使用 View request 以下代码可以将模板转换为 pdf 但它无法将 CSS 加载到模板中 def html t
  • 如何单独捕获这些异常?

    我正在编写一个与 Quickbooks 交互的 Python 程序 连接到 Quickbooks 时 根据问题的不同 我可能会遇到以下两个常见异常之一 pywintypes com error 2147352567 Exception oc
  • Hoare Partitioning算法讲解

    根据许多网站给出的伪代码 我写了这个Hoare分区算法 它采用一个数组 根据给定的主元来分区子数组的开始和结束索引 它工作得很好 但是有人可以解释一下逻辑 它是如何做到这一点的吗 这是代码 def hoare arr start end p
  • Pandas 数据框可对多列和要列出的值进行字典

    我有一个数据框 id key a1 1 a2 1 a3 1 a4 2 a5 2 a6 3 我想创建一本字典key作为机器号 并且id列作为列表 like 1 a1 a2 a3 2 a4 a5 3 a6 我可以先使用 groupby 然后再使
  • 如何使用 PySpark 预处理图像?

    我有一个项目 需要为 1 设置大数据架构 AWS S3 SageMaker 的概念验证使用 PySpark 预处理图像 2 执行 PCA and 3 训练一些机器或深度学习模型 我的问题是了解如何使用 PySpark 操作图像数据 但无法在

随机推荐