我使用的是Python 3,我使用的是jupyter,当我尝试导入qiskit时,显示了以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-578b7f7e9727> in <module>
----> 1 import qiskit
~\AppData\Roaming\Python\Python36\site-packages\qiskit\quantum_info\synthesis\two_qubit_decompose.py in __init__(self, unitary_matrix)
169 # D, P = la.eig(M2) # this can fail for certain kinds of degeneracy
170 for i in range(100): # FIXME: this randomized algorithm is horrendous
--> 171 state = np.random.default_rng(i)
172 M2real = state.normal()*M2.real + state.normal()*M2.imag
173 _, P = la.eigh(M2real)
AttributeError: module 'numpy.random' has no attribute 'default_rng'
我得到的错误与:
使用
'1.16.2'
的numpy版本作为解决方案,您需要将以下行放在文件的顶部:
或者,您当前的numpy版本可能是
<= 1.17
。因此,您需要更新NumPy版本。例如,我在Anaconda environment上将其更新为:目前的版本是:
更新需要时间,因为NumPy有很多依赖项。希望这个问题能在我这边解决
如果您在anaconda中使用jupyter-卸载、重新安装并重新启动内核对我的作用与此类似:AttributeError: module 'numpy' has no attribute '__version__'
您需要NumPy 1.17或更高版本才能拥有Qiskit所需的新RNG功能
相关问题 更多 >
编程相关推荐