在ubuntu下安装Python Moviepy模块导入报错

Moviepy是一个用来处理视频的python第三方库,基于ffmpeg实现的

因有些视频需要处理下,因此就用到了这个Moviepy模块,安装没有问题,但是导入的时候确报错


from moviepy.editor import * 

RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.

上面报的错是找不到ffmpeg exe,或者是没有把imageio_ffmpeg_exe添加到环境变量,但是我在虚拟环境中pip install的,所以应该不是环境变量的问题。

怀疑是版本的问题,把pip升级下:

pip install --upgrade pip

pip uninstall moviepy

pip install moviepy 
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting moviepy
  Downloading http://mirrors.aliyun.com/pypi/packages/fb/32/a93f4af8b88985304a748ca0a66a64eb9fac53d0a9355ec33e713c4a3bf5/moviepy-1.0.0.tar.gz (398kB)
    100% |████████████████████████████████| 399kB 6.1MB/s 
Requirement already satisfied: decorator<5.0,>=4.0.2 in ./venv/lib/python3.6/site-packages (from moviepy) (4.3.0)
Requirement already satisfied: tqdm<5.0,>=4.11.2 in ./venv/lib/python3.6/site-packages (from moviepy) (4.31.1)
Requirement already satisfied: numpy in ./venv/lib/python3.6/site-packages (from moviepy) (1.15.4)
Requirement already satisfied: requests<3.0,>=2.8.1 in ./venv/lib/python3.6/site-packages (from moviepy) (2.21.0)
Requirement already satisfied: proglog<=1.0.0 in ./venv/lib/python3.6/site-packages (from moviepy) (0.1.9)
Collecting imageio<3.0,>=2.5 (from moviepy)
  Downloading http://mirrors.aliyun.com/pypi/packages/af/0a/943c965d372dae0b1f1482677d29030ab834351a61a9a632fd62f27f1523/imageio-2.5.0-py3-none-any.whl (3.3MB)
    100% |████████████████████████████████| 3.3MB 47.6MB/s 
Requirement already satisfied: imageio_ffmpeg>=0.2.0 in ./venv/lib/python3.6/site-packages (from moviepy) (0.2.0)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in ./venv/lib/python3.6/site-packages (from requests<3.0,>=2.8.1->moviepy) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.6/site-packages (from requests<3.0,>=2.8.1->moviepy) (2018.11.29)
Requirement already satisfied: idna<2.9,>=2.5 in ./venv/lib/python3.6/site-packages (from requests<3.0,>=2.8.1->moviepy) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./venv/lib/python3.6/site-packages (from requests<3.0,>=2.8.1->moviepy) (3.0.4)
Requirement already satisfied: pillow in ./venv/lib/python3.6/site-packages (from imageio<3.0,>=2.5->moviepy) (5.3.0)
Installing collected packages: imageio, moviepy
  Running setup.py install for moviepy ... done
Successfully installed imageio-2.5.0 moviepy-1.0.0

还是报错,但是发现在重新install moviepy的时候很多依赖都已经存在了,其中就有这个imageio_ffmpeg,我们把这个卸载掉重新安装,

pip uninstall imageio_ffmpeg 

pip install imageio_ffmpeg 

重新安装导入就可以了

在安装没有问题的时候,但是导入的时候报错,那就可以先查看下依赖包是不是有问题,也有可能是依赖包版本的问题。

我们在pip的时候可以看到moviepy的依赖有:

decorator
tqdm
numpy
requests
proglog
imageio_ffmpeg
urllib3
certifi
idna
chardet
pillow
imageio

 

你可能感兴趣的:(BUG)