Pygame - ImportError:没有名为moviepy.editor的模块

时间:2017-09-01 02:02:52

标签: python python-3.x pygame pip moviepy

MacOS Sierra

Python 3.5.2

➜  fun_python $ pip install moviepy
Requirement already satisfied: moviepy in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already satisfied: tqdm==4.11.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: decorator==4.0.11 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: imageio==2.1.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from imageio==2.1.2->moviepy)
Requirement already satisfied: olefile in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pillow->imageio==2.1.2->moviepy)
➜  fun_python $ pip3 install moviepy
Requirement already satisfied: moviepy in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already satisfied: decorator==4.0.11 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: imageio==2.1.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: tqdm==4.11.2 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from moviepy)
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from imageio==2.1.2->moviepy)
Requirement already satisfied: olefile in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pillow->imageio==2.1.2->moviepy)
➜  fun_python $ brew install cairo
Warning: cairo 1.14.10 is already installed

➜  fun_python $ cat pentagon.py
import numpy as np
import moviepy.editor as mpy
import colorsys
import gizeh as gz

W,H = 256,256
NFACES, R, NSQUARES, DURATION = 5, 0.3,  100, 2

def half(t, side="left"):
    points = gz.geometry.polar_polygon(NFACES, R, NSQUARES)
    ipoint = 0 if side=="left" else NSQUARES/2
    points = (points[ipoint:]+points[:ipoint])[::-1]

    surface = gz.Surface(W,H)
    for (r, th, d) in points:
        center = W*(0.5+gz.polar2cart(r,th))
        angle = -(6*np.pi*d + t*np.pi/DURATION)
        color= colorsys.hls_to_rgb((2*d+t/DURATION)%1,.5,.5)
        square = gz.square(l=0.17*W, xy= center, angle=angle,
                   fill=color, stroke_width= 0.005*W, stroke=(1,1,1))
        square.draw(surface)
    im = surface.get_npimage()
    return (im[:,:W/2] if (side=="left") else im[:,W/2:])


def make_frame(t):
    return np.hstack([half(t,"left"),half(t,"right")])

clip = mpy.VideoClip(make_frame, duration=DURATION)
clip.write_gif("pentagon.gif",fps=15, opt="OptimizePlus")

➜  fun_python $ python pentagon.py
Traceback (most recent call last):
  File "pentagon.py", line 2, in <module>
    import moviepy.editor as mpy
ImportError: No module named moviepy.editor
➜  fun_python

要解决此问题,我尝试安装pygame,但这导致:pip install pygame - SDL.h file not found

pip install pygamepip3 install pygame

0 个答案:

没有答案