Encountered module 'numpy' has no attribute 'float' solution when running python code

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.floatfrom version onwards. 1.24But the code used here is based on an old version Numpy.
View the current numpyversion:
(Use the installation command to view the current numpyversion)

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:

  1. uninstall the originalnumpy
pip uninstall numpy
  1. installed 1.23.5version 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.

Guess you like

Origin blog.csdn.net/qq_39779233/article/details/130095024