写在前面
自己的测试环境:
Ubuntu20.04
一、问题描述
自己运行 python
程序时出现如下报错:
File "/home/wong/.local/lib/python3.8/site-packages/evo/core/lie_algebra.py", line 25, in <module>
import scipy.spatial.transform as sst
File "/usr/lib/python3/dist-packages/scipy/spatial/__init__.py", line 99, in <module>
from .kdtree import *
File "/usr/lib/python3/dist-packages/scipy/spatial/kdtree.py", line 8, in <module>
import scipy.sparse
File "/usr/lib/python3/dist-packages/scipy/sparse/__init__.py", line 229, in <module>
from .base import *
File "/usr/lib/python3/dist-packages/scipy/sparse/base.py", line 8, in <module>
from .sputils import (isdense, isscalarlike, isintlike,
File "/usr/lib/python3/dist-packages/scipy/sparse/sputils.py", line 16, in <module>
supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
File "/usr/lib/python3/dist-packages/scipy/sparse/sputils.py", line 16, in <listcomp>
supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
File "/home/wong/.local/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'
二、解决方法
首先检查自己的 numpy
版本,自己的 numpy
是 1.24.4
,所以可能是版本太高了,因此安装低版本的 numpy
,比如 1.21.1
版本:
pip install numpy==1.21
安装成功后,再次运行 python
程序即可解决问题
参考链接
[1] 小桥流水—人工智能. 完美解决AttributeError: module ‘numpy‘ has no attribute ‘typeDict‘ [EB/OL]. https://blog.csdn.net/qlkaicx/article/details/134571905, 2023-11-23/2024-08-26.