简体   繁体   中英

executable with pyinstaller does not work with moviepy?

I have a script that needs moviepy, I wanted to have it as an executable but that doesn't seem to work, does anyone know if there is a workaround for this?

from moviepy.editor import *

Console:

./run 
Traceback (most recent call last):
  File "run.py", line 21, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller/loader/pyimod02_importers.py", line 493, in exec_module
  File "moviepy/editor.py", line 87, in <module>
  File "<string>", line 1, in <module>
AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
[75721] Failed to execute script 'run' due to unhandled exception!
  1. First create a virtual environment using venv.

  2. Then create a requirements file, if you haven't done already.

    pip freeze > requirements.txt

  3. Use this requirements file in your pyinstaller, while creating executable.

    path\to\pyinstaller.exe --onefile --paths \venv_location\file.py

  4. You can go through PyInstaller Docs for more details.

Ok I got it to run, but it's not pretty ️

If someone has a better solution please write

My folder structure now looks like this:

.
+-- exe.exe
+-- .script
    +-- run.py

in exe.exe is only that:

from subprocess import call

call(["python3", ".script/run.py"])

The main point was to start the script without terminal, and that works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM