Python & MoviePy vector graphics test

Author’s blog post about using MoviePy to animate vector graphics here
MoviePy PyPi page here
Gizeh GitHub page here

Installation

..at PyPi page they state to install MoviePy simply by: pip install moviepy
..not that fast bro, MoviePy 1.0 runs only on python 3, so i had to use older version for my rusty old python 2.7.. sudo pip install moviepy==0.2.3.5
Successfully installed moviepy decorator imageio tqdm enum34 futures
Cleaning up...

well..that worked, but package itself uses lots of other packages to work..
..on Linux Mint 17.3 i went into dependency hell, have a good luck trying..

..to run examples i had to install gizeh..
sudo pip install gizeh

RuntimeError: cairocffi does not support Python 2.x anymore. Please use Python 3 or install an older version of cairocffi.

solved by using older version: sudo pip install cairocffi==0.9.0

trying to run examples from authors blog:
from moviepy.editor import *
File "/usr/local/lib/python2.7/dist-packages/moviepy/editor.py", line 26, in
imageio.plugins.ffmpeg.download()
File "/usr/local/lib/python2.7/dist-packages/imageio/plugins/ffmpeg.py", line 40, in download
"imageio.ffmpeg.download() has been deprecated. "
RuntimeError: imageio.ffmpeg.download() has been deprecated. Use 'pip install imageio-ffmpeg' instead.'

solution found here
sudo pip install imageio==2.4.1

problems with pillow setup:
had to manually install package „libjpeg-dev“ via sudo apt-get install libjpeg-dev or installation failed

another problem right on:
ImportError: Imageio Pillow requires Pillow, not PIL!

so i tried:
sudo pip install pillow
Requirement already satisfied (use --upgrade to upgrade): pillow in /usr/lib/python2.7/dist-packages
Cleaning up...

lol?

found issue: https://github.com/Zulko/moviepy/issues/748
being rather issue of imageio: https://github.com/imageio/imageio/issues/322

– yes, there is no pillow there 😀
oh really?

sudo pip install --target=/usr/local/lib/python2.7/dist-packages/ --upgrade pillow
...
--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 6.0.0
platform linux2 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4]
--------------------------------------------------------------------
...
Successfully installed pillow
Cleaning up..
.

would the example from author’s blog post work after all this? of course NOT 😀

[MoviePy] Building file circle.gif with imageio
0%| | 0/31 [00:00
Traceback (most recent call last):
File "/home/k/Plocha/PYTHON/MOVIEPY_TESTS/moviepy_test_1.py", line 18, in
clip.write_gif("circle.gif",fps=15, opt="OptimizePlus", fuzz=10)
File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-56>", line 2, in write_gif
File "/usr/local/lib/python2.7/dist-packages/moviepy/decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "</usr/local/lib/python2.7/dist-packages/decorator.pyc:decorator-gen-55>", line 2, in write_gif
File "/usr/local/lib/python2.7/dist-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "/usr/local/lib/python2.7/dist-packages/moviepy/video/VideoClip.py", line 456, in write_gif
progress_bar=progress_bar)
File "/usr/local/lib/python2.7/dist-packages/moviepy/video/io/gif_writers.py", line 293, in write_gif_with_image_io
writer.append_data(frame)
File "/usr/local/lib/python2.7/dist-packages/imageio/core/format.py", line 500, in append_data
return self._append_data(im, total_meta)
File "/usr/local/lib/python2.7/dist-packages/imageio/plugins/pillowmulti.py", line 113, in _append_data
self._writer.add_image(im, duration, dispose)
File "/usr/local/lib/python2.7/dist-packages/imageio/plugins/pillowmulti.py", line 165, in add_image
im_pil = self.converToPIL(im_rect, self.opt_quantizer, self.opt_palette_size)
File "/usr/local/lib/python2.7/dist-packages/imageio/plugins/pillowmulti.py", line 353, in converToPIL
im_pil = ndarray_to_pil(im, "gif")
File "/usr/local/lib/python2.7/dist-packages/imageio/plugins/pillow.py", line 645, in ndarray_to_pil
array_buffer = arr.tobytes()
AttributeError: 'numpy.ndarray' object has no attribute 'tobytes'

..being issue: https://github.com/Zulko/moviepy/issues/499
..so sudo pip install numpy --upgrade

Successfully installed numpy
Cleaning up...

YAY IT WOIRX NOW !!!

Příspěvek byl publikován v rubrice Software a jeho autorem je KillAdmin. Můžete si jeho odkaz uložit mezi své oblíbené záložky nebo ho sdílet s přáteli.