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

1

1

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?

Scarborough answered 13/1 at 7:56 Comment(0)
P
1

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 note that the newest version of scikit-video is from 2018.

Pariah answered 13/1 at 19:31 Comment(2)
Thanks, I will try this. Any idea if scikit-video is still in development or is it better to switch to some other library for reading/writing videos?Scarborough
Well there have been some updates on the github in the last months: github.com/scikit-video/scikit-video This even includes some changes for numpy >= 1.24. So I would say it is not abandoned but I cannot say if its still in active development. Even if it is not, there is no reason to not use it as long as it does what you need.Pariah

© 2022 - 2024 — McMap. All rights reserved.