报错如图:
AttributeError: module 'numpy' has no attribute 'int'.
问题原因:新版本的numpy里面没有np.int了。
【推荐】方法一:找到报错的位置,把np.int改成int就解决了
改成
方法二:
1.先查看现在安装的numpy是什么版本:conda list
降低numpy版本,安装1.20以下的版本,先卸载当前的2.0.1版本:pip uninstall numpy
可以安装1.19.5版本:pip install numpy==1.19.5
出现报错
是由于缺少 distutils
模块,而这个模块是构建 numpy==1.19.0
时所需要的依赖。具体问题是 distutils.msvccompiler
模块未找到,导致无法生成包的元数据。
1.安装distutils:conda install setuptools
2.安装wheel:pip install wheel
3.最后安装1.19.5版本的numpy
现在就能看到numpy版本是1.19.5了
遇到pandas
和 numpy
版本不兼容这里pandas
版本要求 numpy
版本至少为 1.22.4,而你当前使用的 numpy
版本是 1.19.5。
所以降低pandas版本以适配numpy版本为1.22.4
1.先卸载当前的pandas:pip uninstall pandas
2.安装兼容版本的pandas:通过以下命令安装与 numpy 1.19.5
兼容的 pandas
版本,例如 pandas 1.3.5
:pip install pandas==1.3.5
3.确认版本匹配:安装完成后,你可以检查当前安装的 pandas
和 numpy
版本,确保它们是兼容的:
这样,pandas 1.3.5
应该会与 numpy 1.19.5
兼容,从而解决版本不匹配的问题。
遇到matplotlib和 numpy
版本不兼容
降低 matplotlib
版本
因为希望保持当前的 numpy 1.19.5
版本不变,可以通过安装与其兼容的较低版本的 matplotlib
。
-
卸载当前的
matplotlib
:pip uninstall matplotlib -
安装兼容的
matplotlib
版本(例如matplotlib 3.4.3
):pip install matplotlib==3.4.3 -
验证安装: 确保安装了正确的
matplotlib
版本:python -c "import matplotlib; print(matplotlib.__version__)"