拿什么拯救你:scikit-video

文章讲述了在使用scikit-video库时遇到的与numpy版本不兼容的问题,由于scikit-video依赖的numpy.float被废弃,提出了两种解决方案:降级numpy版本或临时修改导入语句。
摘要由CSDN通过智能技术生成

scikit-video

今天要用到一段用到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 videonumpy的版本居然不兼容:scikit video最后发布是2018年,已经好几年不再更新了,而numpy在1.20后废止了原来的numpy.floatscikit-video中用到了这个废止的属性。

解决方法

  • 方法1:安装numpy 1.24以前的版本
  • 方法2:
    import numpy
    numpy.float = numpy.float64
    numpy.int = numpy.int_
    import skvideo.io
    

详情见:https://github.com/scikit-video/scikit-video/issues/154

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值