当前位置: 代码迷 >> 综合 >> line 117, in linspace num = operator.index(num)TypeError: 'numpy.float64' object cannot be interp
  详细解决方案

line 117, in linspace num = operator.index(num)TypeError: 'numpy.float64' object cannot be interp

热度:91   发布时间:2024-01-19 11:27:08.0

记录一下错误和解决方案

C:\Users\wei\.virtualenvs\pyqt51-EL5sW8oD\Scripts\python.exe E:/work/facode/0finger/app/enhance/image_enhance.py
Traceback (most recent call last):
  File "C:\Users\wei\.virtualenvs\pyqt51-EL5sW8oD\lib\site-packages\numpy\core\function_base.py", line 117, in linspace
    num = operator.index(num)
TypeError: 'numpy.float64' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:/work/facode/0finger/app/enhance/image_enhance.py", line 68, in <module>
    img = image_enhance(img)
  File "E:/work/facode/0finger/app/enhance/image_enhance.py", line 32, in image_enhance
    newim = ridge_filter(normim, orientim, freq, kx, ky)  # create gabor filter and do the actual filtering
  File "E:\work\facode\0finger\app\enhance\ridge_filter.py", line 59, in ridge_filter
    x, y = np.meshgrid(np.linspace(-sze, sze, (2 * sze + 1)), np.linspace(-sze, sze, (2 * sze + 1)))
  File "<__array_function__ internals>", line 6, in linspace
  File "C:\Users\wei\.virtualenvs\pyqt51-EL5sW8oD\lib\site-packages\numpy\core\function_base.py", line 121, in linspace
    .format(type(num)))
TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

Process finished with exit code 1
找了很多网上的改正方法,没有找到导致错误的代码 看到网上说更换

原因是numpy1.18.2版本与其他软件的兼容性的问题导致。
解决办法:将numpy1.18.2的版本降为1.17,测试可以正常运行。其他可行办法尚未测试。
结果如下:

  相关解决方案