1. Problem description
Encountered the following problems when running python code
module ‘numpy‘ has no attribute ‘float‘
Two, the solution
The reason for this workaround is mainly because it was removed np.float
from version onwards. 1.24
But the code used here is based on an old version Numpy
.
View the current numpy
version:
(Use the installation command to view the current numpy
version)
pip install numpy
反馈结果:
Requirement already satisfied: numpy in /home/wong/.local/lib/python3.8/site-packages (1.24.1)
# 说明我当前电脑的 numpy 版本是 1.24.1
So there are two solutions:
one is to update the currently used python code to not use it np.float
.
The other is to downgrade your Numpy version to 1.23.5
.
Specific steps:
- uninstall the original
numpy
pip uninstall numpy
- installed
1.23.5
version ofnumpy
pip install -U numpy==1.23.5
reference link
[1] Xi Yangz. Encountered module 'numpy' has no attribute 'float' [EB/OL]. https://blog.csdn.net/Yao_Wan/article/details/128767735, 2023-01-26/2023 -04-11.