Python 3.10 QuTip:属性错误:无法设置属性“format”

42fyovps  于 2023-06-28  发布在  Python
关注(0)|答案(1)|浏览(134)

我正在尝试设置一个简单的docker容器来使我的代码可移植。下面是我开始使用的docker容器设置

docker run -it --name qutip_portble python:3.10.9-slim bash

一旦docker容器启动,我就安装一些包,如下所示

pip install qutip
pip install matplotlib

这两个安装成功,没有任何错误。但是,当我尝试在python中运行以下导入时

import qutip

我得到以下错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/qutip/__init__.py", line 106, in <module>
    from qutip.qobj import *
  File "/usr/local/lib/python3.10/site-packages/qutip/qobj.py", line 2526, in <module>
    import qutip.superop_reps as sr
  File "/usr/local/lib/python3.10/site-packages/qutip/superop_reps.py", line 74, in <module>
    _SINGLE_QUBIT_PAULI_BASIS = (identity(2), sigmax(), sigmay(), sigmaz())
  File "/usr/local/lib/python3.10/site-packages/qutip/operators.py", line 508, in identity
    return qeye(dims)
  File "/usr/local/lib/python3.10/site-packages/qutip/operators.py", line 488, in qeye
    return Qobj(fast_identity(size),
  File "/usr/local/lib/python3.10/site-packages/qutip/fastsparse.py", line 389, in fast_identity
    return fast_csr_matrix((data,ind,ptr),shape=(N,N))
  File "/usr/local/lib/python3.10/site-packages/qutip/fastsparse.py", line 55, in __init__
    self.format = 'csr'
AttributeError: can't set attribute 'format'

我在编写任何代码之前的import阶段就得到了这个错误。因此,我假设这是因为一些设置问题。任何帮助将不胜感激。

7gcisfzg

7gcisfzg1#

**解决方案(感谢liginity):**在设置软件包时使用以下命令显式安装scipy版本1.10.1

pip install scipy==1.10.1
pip install qutip
pip install matplotlib

相关问题