-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building an executable with PyInstaller #263
Comments
Maybe it is due to the fact that ffmpeg is not bundled and is downloaded on trying to execute the moviepy imported code for the first time. Hence, because of that, it is not explicitly defined as a dependency and pyinstaller is unable to bundle that together leading to the following error. I am getting the same error. |
Thanks for confirming this issue. |
Last week I got a chance to go dirty with moviepy module source in
Moviepy uses a neat "exec" trick to dynamically import all the modules at fx level. Pyinstaller fails to recognise that and hence, it throws up the following error. SolutionIt is more of a hack. Replace the for loop and exec statement with actual import statements.
Do the same for
Build your application once to generate pyc of your changes in moviepy folder too. Then, build the executable with pyinstaller in the usual way and try to run it. It will throw the same error as above. Then, you should go to the respective folder ( Try running the executable once again and it will work. |
I don't have much time to look into this but someone seems to have fixed my very hackish code for fx.all in this in pull request: #275 because they had apparently the same problem but with pyfreeze. Can you guys try Pyinstaller on his version and report back ? |
@Zulko I can confirm that it does not work. Pyinstaller, still, is not able to bundle the changes , probably due to exec still being there. |
thank you very much @pratikone for your solution, it worked for me, even that i dont understand it fully. |
Just pinging here, any updates? I have the same issue. It seems like the relative app directory. If you open the app from the package contents, it runs, but double clicking on the icon from /Applications fails. Is the suggested change the moviepy source still best practice? |
Okay, I've tried the suggested fix but no luck. Let me document my work here. The problemMy app successful runs in the following conditions.
but, it cannot open on double click of icon. No error message. No system log on console, nothing. The error only occurred after moviepy. Removing moviepy fixes the error. Attempts
went to that dir, deleted the .pyc and changed the init to do direct imports as noted above.
I did this for both the /video/fx/all and the audio/fx/all modules. I ran my app a couple times, but i did notice that the .pyc are not recreated. Could this be an issue? I deleted them initially.
Double click fails, but from terminal
works fine. I'm struggling with debugging avenues. Suggestions? |
Add on here. I added
and rebuilt with pyinstaller. I got
but I do have ffmpeg in my path!
Not only that, what is more curious is that my .App has been using ffmpeg through opencv video capture for years. If not, I would have never been able to read video. Its bundled in, and never before has it had problems finding it. I'm now looking to see if moviepy has changed the env variables in some way. Edit #1 Perhaps I was a little hasty in saying that I had ffmpeg from opencv. What opencv has is the ffmpeg .dll, so it is different. I'm now going down the route of editing pyinstaller to include the ffmpeg binary in the build and then editing the moviepy defaults config. |
I hope I am commenting in the right way but at trying to create an exe file with pyinstaller and after following all the steps presented in this issue and also modifying the moviepy library and doing my own local copy changing the moviepy/video/fx/all/init.py and moviepy/audio/fx/all/init.py now I have the error below: Exception in Tkinter callback Someone has a suggestion about this? or I´m doing something wrong? |
Actually you don't strictly have to edit the library source before bundling up. from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.VideoClip import ImageClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.audio.io.AudioFileClip import AudioFileClip
from moviepy.audio.AudioClip import AudioClip
from moviepy.editor import concatenate_videoclips,concatenate_audioclips,TextClip,CompositeVideoClip
from moviepy.video.fx.accel_decel import accel_decel
from moviepy.video.fx.blackwhite import blackwhite
from moviepy.video.fx.blink import blink
from moviepy.video.fx.colorx import colorx
from moviepy.video.fx.crop import crop
from moviepy.video.fx.even_size import even_size
from moviepy.video.fx.fadein import fadein
from moviepy.video.fx.fadeout import fadeout
from moviepy.video.fx.freeze import freeze
from moviepy.video.fx.freeze_region import freeze_region
from moviepy.video.fx.gamma_corr import gamma_corr
from moviepy.video.fx.headblur import headblur
from moviepy.video.fx.invert_colors import invert_colors
from moviepy.video.fx.loop import loop
from moviepy.video.fx.lum_contrast import lum_contrast
from moviepy.video.fx.make_loopable import make_loopable
from moviepy.video.fx.margin import margin
from moviepy.video.fx.mask_and import mask_and
from moviepy.video.fx.mask_color import mask_color
from moviepy.video.fx.mask_or import mask_or
from moviepy.video.fx.mirror_x import mirror_x
from moviepy.video.fx.mirror_y import mirror_y
from moviepy.video.fx.painting import painting
from moviepy.video.fx.resize import resize
from moviepy.video.fx.rotate import rotate
from moviepy.video.fx.scroll import scroll
from moviepy.video.fx.speedx import speedx
from moviepy.video.fx.supersample import supersample
from moviepy.video.fx.time_mirror import time_mirror
from moviepy.video.fx.time_symmetrize import time_symmetrize
from moviepy.audio.fx.audio_fadein import audio_fadein
from moviepy.audio.fx.audio_fadeout import audio_fadeout
from moviepy.audio.fx.audio_left_right import audio_left_right
from moviepy.audio.fx.audio_loop import audio_loop
from moviepy.audio.fx.audio_normalize import audio_normalize
from moviepy.audio.fx.volumex import volumex even though this is still not desirable, it is a working hack for the time being. |
has
So importing the editor module has the same problem. It also means you can't chain commands (e.g. |
Closing this issue as it's old and references an older Python version we no longer support. Do report back – following our issue template – if the problem persists when you try with the latest master (not the last PyPI release). Ideally, you'd open a new issue for that. |
I had the same problem with python 3.10.5 on windows 10 with moviepy 1.0.3 and pyinstaller 5.7.0. The @Zenahr answer fixed my problem. |
Hi,
I've been using the MoviePy library (which is very awesome) to generate some teaching videos. Now, to make my video script easier to use for my colleagues, I want to turn the python script into a single executable using PyInstaller.
PyInstaller runs fine, and does it's thing - creates the executable, but when I try to run it, i get the following error:
I've tried creating other exec files too, but when I add a
from moviepy.editor import *
or any other import from MoviePy I keep getting the same error.I'm running Python 2.7 on a 64-bit Windows 7 PC.
The text was updated successfully, but these errors were encountered: