今天要用到一段用到scikit-video的旧代码,先用conda创建了一个Python运行环境:
conda create -n scivideo python=3.10
conda activate scivideo
conda install scikit-video
conda安装的sci-video版本为1.1.11,numpy的版本为1.25.1。安装后先用最简单的代码测试一下环境是否正常:
import skvideo.io
import skvideo.datasets
videodata = skvideo.io.vread(skvideo.datasets.bigbuckbunny())
BANG!!!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "skvideo/io/io.py", line 144, in vread
reader = FFmpegReader(fname, inputdict=inputdict, outputdict=outputdict, verbosity=verbosity)
File "skvideo/io/ffmpeg.py", line 44, in __init__
super(FFmpegReader,self).__init__(*args, **kwargs)
File "io/abstract.py", line 87, in __init__
if np.float(parts[1]) == 0.:
File "numpy/__init__.py", line 313, 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.
scikit video
和numpy
的版本居然不兼容:scikit video
最后发布是2018年,已经好几年不再更新了,而numpy
在1.20后废止了原来的numpy.float
。scikit-video
中用到了这个废止的属性。
解决方法:
- 方法1:安装
numpy
1.24以前的版本 - 方法2:
import numpy numpy.float = numpy.float64 numpy.int = numpy.int_ import skvideo.io