Loading video using scikit-video latest version and numpy latest version gives numpy has no float attribute error

171 Views Asked by At

I have installed the latest version of scikit-video=1.1.11 and the latest version of numpy=1.26.1. When trying to load a video as

>>> import skvideo.io
>>> skvideo.io.vread('video_path.mp4')

I get the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/envs/snb/lib/python3.10/site-packages/skvideo/io/io.py", line 144, in vread
    reader = FFmpegReader(fname, inputdict=inputdict, outputdict=outputdict, verbosity=verbosity)
  File "/home/user/anaconda3/envs/snb/lib/python3.10/site-packages/skvideo/io/ffmpeg.py", line 44, in __init__
    super(FFmpegReader,self).__init__(*args, **kwargs)
  File "/home/user/anaconda3/envs/snb/lib/python3.10/site-packages/skvideo/io/abstract.py", line 87, in __init__
    if np.float(parts[1]) == 0.:
  File "/home/user/anaconda3/envs/snb/lib/python3.10/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?

The error goes away if I install older version of numpy=1.23.5 as suggested in this answer. The answer notes that float attribute is deprecated in numpy=1.20 and removed in numpy=1.24.

So, why has scikit-video not updated this in their latest version? Is there no way to use latest numpy with scikit-video?

1

There are 1 best solutions below

2
Oskar Hofmann On

This is an open issue in the scikit-video github repository.

One possible solution (as proposed in that issue) is using

import numpy
numpy.float = numpy.float64
numpy.int = numpy.int_

Or using an older numpy version as you proposed.

As far as I see, there is no special reason for it apart from that this change in numpy has not been taken into account yet. Please not that the newest version of scikit-video is from 2018.