赞
踩
Anaconda
虚拟环境下安装使用的python
的imageio[ffmpeg]
包的时候,报错:
FileNotFoundError: Package has no location <module 'imageio_ffmpeg.binaries' (namespace)>
重新安装下载还是一直报错,可能是曾经下载过ffmpeg
并且添加了系统环境变量。将该变量删除以后重启仍然报错。报错信息提示不能定位ffmpeg
的二进制文件夹,然而明明可以在安装库imageio_ffmpeg
的路径里面找到该二进制文件夹1。我的在这里:
D:\Anaconda\envs\pytorch_cpu\Lib\site-packages\imageio_ffmpeg\binaries
注意到_utils.py
中的get_ffmpeg_exe
函数:
def get_ffmpeg_exe(): """ Get the ffmpeg executable file. This can be the binary defined by the IMAGEIO_FFMPEG_EXE environment variable, the binary distributed with imageio-ffmpeg, an ffmpeg binary installed with conda, or the system ffmpeg (in that order). A RuntimeError is raised if no valid ffmpeg could be found. """ # 1. Try environment variable. - Dont test it: the user is explicit here! exe = os.getenv("IMAGEIO_FFMPEG_EXE", None) if exe: return exe # Auto-detect exe = _get_ffmpeg_exe() if exe: return exe # Nothing was found raise RuntimeError( "No ffmpeg exe could be found. Install ffmpeg on your system, " "or set the IMAGEIO_FFMPEG_EXE environment variable." )
该函数会首先查找IMAGEIO_FFMPEG_EXE
环境变量,于是新增环境变量12
IMAGEIO_FFMPEG_EXE=D:\Anaconda\envs\pytorch_cpu\Lib\site-packages\imageio_ffmpeg\binaries\ffmpeg-win64-v4.2.2.exe
再次测试能否正常运行,测试代码:
import imageio_ffmpeg
print(imageio_ffmpeg.get_ffmpeg_version())
输出
D:\Anaconda\envs\pytorch_cpu\python.exe ...\test.py
4.2.2
Process finished with exit code 0
输出版本号则说明测试成功
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。