AttributeError: module ‘numpy‘ has no attribute ‘typeDict‘

问题描述:运行一个网上下载的PyQt5代码,出现了AttributeError: module 'numpy' has no attribute 'typeDict'的错误。具体如下:

Traceback (most recent call last):
  File "F:/PyQt5/Javacr/main.py", line 16, in 
    from models.experimental import attempt_load
  File "F:\PyQt5\Javacr\models\experimental.py", line 11, in 
    from models.common import Conv
  File "F:\PyQt5\Javacr\models\common.py", line 27, in 
    from utils.plots import Annotator, colors, save_one_box
  File "F:\PyQt5\Javacr\utils\plots.py", line 16, in 
    import seaborn as sn
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\seaborn\__init__.py", line 2, in 
    from .rcmod import *  # noqa: F401,F403
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\seaborn\rcmod.py", line 7, in 
    from . import palettes
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\seaborn\palettes.py", line 9, in 
    from .utils import desaturate, get_color_cycle
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\seaborn\utils.py", line 10, in 
    from scipy import stats
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\stats\__init__.py", line 384, in 
    from .stats import *
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\stats\stats.py", line 179, in 
    from scipy.spatial.distance import cdist
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\spatial\__init__.py", line 97, in 
    from .kdtree import *
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\spatial\kdtree.py", line 8, in 
    import scipy.sparse
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\sparse\__init__.py", line 229, in 
    from .base import *
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\sparse\base.py", line 8, in 
    from .sputils import (isdense, isscalarlike, isintlike,
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\sparse\sputils.py", line 17, in 
    supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\site-packages\scipy\sparse\sputils.py", line 17, in 
    supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
  File "C:\Users\aoqia\anaconda3\envs\yolov5_pyqt5\lib\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.18.5,我安装了numpy==1.24.3版本的,具体如下图所示:

AttributeError: module ‘numpy‘ has no attribute ‘typeDict‘_第1张图片

图1 项目要求的numpy版本

AttributeError: module ‘numpy‘ has no attribute ‘typeDict‘_第2张图片

图2 默认安装的 numpy版本

解决办法:将numpy版本降下来。比如安装1.2.1版本的numpy。

pip install numpy==1.21

你可能感兴趣的:(numpy,python,开发语言)