简体   繁体   中英

Pyinstaller - How to hidden import moviepy?

I want to convert my script to an .exe and have tried it with pyinstaller. The problem is that moviepy is not imported. I imported moviepy as import moviepy.editor as me (in script.py).

So i tried the hidden import. The command was: pyinstaller --onefile --hidden-import=moviepy script.py

output:

3601 INFO: Analyzing hidden import 'moviepy'  
3601 ERROR: Hidden import 'moviepy' not found

Could someone help me? Thanks :)

hidden-imports will only add the module itself and not its dependencies. It seems that PyInstaller can't handle moviepy automatically, and it would lack some dependencies like imageio-ffmpeg , so you can use Tree class and add both moviepy and imageio-ffmpeg to final executable.

Your spec file should look like this: (Remember to edit the module path based on your Python directory)

# -*- mode: python -*-

block_cipher = None


a = Analysis(
    ...
)
a.datas += Tree("./env/Lib/site-packages/moviepy", prefix='moviepy')
a.datas += Tree("./env/Lib/site-packages/imageio_ffmpeg/", prefix='imageio_ffmpeg')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
...

Finally, generate your executable with:

pyinstaller script.spec

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