报错详情:


原因是因为np.int在numpy1.20已经被废弃掉了,可以通过

pip show numpy

在命令行里查看。


现在使用的是np.int_ 或者 np.int32 或者 np.int64

猜测原因

但这个报错是在我自己的site-packages里的numpy的报错,我怀疑可能是numpy本身的问题,所以通过命令

pip uninstall numpy

把这个numpy给uninstall了

大致方法流程:

  1. uninstall numpy
  2. 然后删掉numpy的whl文件,再去python扩展包网页下载一个版本匹配的whl文件
  3. 把whl文件放在script文件夹里面,然后通过pip install numpy-xxxx.whl安装numpy

具体:

1.如何选择下载哪一个呢?

使用命令:

pip debug --verbose

查看当前python支持的版本

D:\app\Scripts>D:\app\python.exe -m pip debug --verboseWARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.pip version: pip 22.3.1 from D:\app\lib\site-packages\pip (python 3.8)sys.version: 3.8.3 (default, Jul2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]sys.executable: D:\app\python.exesys.getdefaultencoding: utf-8sys.getfilesystemencoding: utf-8locale.getpreferredencoding: cp936sys.platform: win32sys.implementation:name: cpython'cert' config value: Not specifiedREQUESTS_CA_BUNDLE: NoneCURL_CA_BUNDLE: Nonepip._vendor.certifi.where(): D:\app\lib\site-packages\pip\_vendor\certifi\cacert.pempip._vendor.DEBUNDLED: Falsevendored library versions:CacheControl==0.12.11colorama==0.4.5distlib==0.3.6distro==1.7.0msgpack==1.0.4packaging==21.3pep517==0.13.0platformdirs==2.5.2pyparsing==3.0.9requests==2.28.1certifi==2022.09.24chardet==5.0.0idna==3.4urllib3==1.26.12rich==12.5.1 (Unable to locate actual module version, using vendor.txt specified version)pygments==2.13.0typing_extensions==4.4.0 (Unable to locate actual module version, using vendor.txt specified version)resolvelib==0.8.1setuptools==44.0.0 (Unable to locate actual module version, using vendor.txt specified version)six==1.16.0tenacity==8.1.0 (Unable to locate actual module version, using vendor.txt specified version)tomli==2.0.1webencodings==0.5.1 (Unable to locate actual module version, using vendor.txt specified version)Compatible tags: 30cp38-cp38-win_amd64cp38-abi3-win_amd64cp38-none-win_amd64cp37-abi3-win_amd64cp36-abi3-win_amd64cp35-abi3-win_amd64cp34-abi3-win_amd64cp33-abi3-win_amd64cp32-abi3-win_amd64py38-none-win_amd64py3-none-win_amd64py37-none-win_amd64py36-none-win_amd64py35-none-win_amd64py34-none-win_amd64py33-none-win_amd64py32-none-win_amd64py31-none-win_amd64py30-none-win_amd64cp38-none-anypy38-none-anypy3-none-anypy37-none-anypy36-none-anypy35-none-anypy34-none-anypy33-none-anypy32-none-anypy31-none-anypy30-none-any

重点关注后面的,就是支持的版本的名称,也就是后面whl文件你要修改的名字

cp38-cp38-win_amd64cp38-abi3-win_amd64cp38-none-win_amd64cp37-abi3-win_amd64cp36-abi3-win_amd64cp35-abi3-win_amd64cp34-abi3-win_amd64cp33-abi3-win_amd64cp32-abi3-win_amd64py38-none-win_amd64py3-none-win_amd64py37-none-win_amd64py36-none-win_amd64py35-none-win_amd64py34-none-win_amd64py33-none-win_amd64py32-none-win_amd64py31-none-win_amd64py30-none-win_amd64cp38-none-anypy38-none-anypy3-none-anypy37-none-anypy36-none-anypy35-none-anypy34-none-anypy33-none-anypy32-none-anypy31-none-anypy30-none-any

这些都是可以下载的版本
因为我python版本是3.8.3,所以我选择的是

38代表python版本,64代表64位

2.修改文件名:

如果文件名不规范,不符合上面支持的格式,在pip install numpy-xxx.whl时就会出现

numpy-1.19.5+mkl-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

这样的的报错

改成这样就好啦:保证最后的cp38-cp38-win_amd64在上面支持的格式中出现

3.安装whl文件:


出现Successfull installed就安装好啦!

用python验证一下:或者直接输入python,我这里是指定了python。

然后就没有那个错误啦!